#include //include the library code: LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); //initialize the library with interface pins //--------------------------------------- int sensorValueA0,sensorValueA4,sensorValueA5,sensorValueA6,sensorValueA7; //value read from P1.x port float voltageA0,voltageA4,voltageA5,voltageA6,voltageA7; //value converted to real Volts long time_seconds = 0; //--------------------------------------- void setup() { pinMode(PUSH2, INPUT_PULLUP); lcd.begin(20, 2); //set up the LCD's (VFD display) number of columns and rows: lcd.print("Msp430g2553 & Linux"); //Print a message to LCD lcd.setCursor(0, 1); lcd.print("DataLogger SK_2015"); delay(1000); for (int positionCounter = 0; positionCounter < 20; positionCounter++) { lcd.scrollDisplayLeft(); //scroll one position left delay(10);}//wait a bit delay(500); lcd.setCursor(0, 0); lcd.print("USB is not ready yet"); lcd.setCursor(0, 1); lcd.print("Wait 10 second. "); for (int positionCounter = 0; positionCounter < 20; positionCounter++) { lcd.scrollDisplayLeft(); //scroll one position left delay(10);} //wait a bit lcd.setCursor(20, 0); lcd.print(" "); lcd.setCursor(20, 1); lcd.print(" "); int i; //temporary variable, int for (i=10;i>0;i--){ //10 second delay lcd.setCursor(5, 1); lcd.print(" "); lcd.setCursor(6, 1); lcd.print(i-1); //print seconds, back counter delay(1000);} for (int positionCounter = 0; positionCounter < 20; positionCounter++) { lcd.scrollDisplayLeft(); //scroll one position left delay(10);}//wait a bit delay(500); lcd.setCursor(0, 0); lcd.print("Setup Linux computer"); lcd.setCursor(0, 1); lcd.print("Run \" dmesg \" first "); for (int positionCounter = 0; positionCounter < 20; positionCounter++) { lcd.scrollDisplayLeft(); //scroll one position left delay(10);} //wait a bit delay(3000); lcd.setCursor(20, 0); lcd.print("#cat /dev/ttyACM0 >>"); lcd.setCursor(20, 1); lcd.print("& press S2 to START!"); for (int positionCounter = 0; positionCounter < 20; positionCounter++) { lcd.scrollDisplayLeft(); //scroll one position left delay(10);} //wait a bit while(analogRead(5) > 500) delay(100); //wait to press button S2 lcd.setCursor(20, 0); lcd.print("We began to transmit"); lcd.setCursor(20, 1); lcd.print("data via serial port"); lcd.setCursor(0, 0); lcd.print(" "); lcd.setCursor(0, 1); lcd.print(" "); Serial.begin(9600); //initialize serial communications at 9600 bps: Serial.print("\n"); //new blank line Serial.print("5 ch. voltmeter, 5,7,18,26,51V, SN.0013, ChemLab_18, Room 402, SK\n"); // Lab No <--- Serial.print("\n"); Serial.print("MSP430G2553 measures voltages at P1.0, P1.4, P1.5, P1.6 and P1.7\n"); Serial.print("Inputs: P1.0<51V, P1.4<26V, P1.5<18V, P1.6<7.3V and P1.7<4.9V\n"); Serial.print("and outputs (Volts) via the serial port each 1 min.\n"); Serial.print("\n"); Serial.print("Time(m)\tP1.0(V)\tP1.4(V)\tP1.5(V)\tP1.6(V)\tP1.7(V)\n"); } //--------------------------------------- void loop() { while (((millis())%992) != 0) //992 - corrected timing for 1 sec. <----- sensorValueA0 = analogRead(A0); //read analog voltage, range 1-1023, int sensorValueA4 = analogRead(A4); sensorValueA5 = analogRead(A5); sensorValueA6 = analogRead(A6); sensorValueA7 = analogRead(A7); voltageA0 = ((sensorValueA0*51.53)/1024); //convert to Volts, x.xV = 1024 counts voltageA4 = ((sensorValueA4*26.26)/1024); voltageA5 = ((sensorValueA5*18.64)/1024); voltageA6 = ((sensorValueA6*7.341)/1024); voltageA7 = ((sensorValueA7*4.964)/1024); if ((time_seconds)%60 == 0) { //<--------------------------------------- Serial.print(time_seconds/60);Serial.print("\t" ); //print to serial, TAB Serial.print(voltageA0); Serial.print("\t" ); Serial.print(voltageA4); Serial.print("\t" ); Serial.print(voltageA5); Serial.print("\t" ); Serial.print(voltageA6); Serial.print("\t" ); Serial.print(voltageA7); Serial.print("\n"); //new line for (int positionCounter = 0; positionCounter < 40; positionCounter++) { lcd.scrollDisplayLeft(); delay(4);}} //scroll one position left <-------------------------------- lcd.setCursor(20, 0); //display was shifted by 20 characters lcd.print(voltageA0);lcd.print("V ");//print to LCD (to VFD display) lcd.print(voltageA4);lcd.print("V "); lcd.print(voltageA5);lcd.print("V "); lcd.setCursor(20, 1); lcd.print(voltageA6);lcd.print("V "); lcd.print(voltageA7);lcd.print("V "); lcd.print(time_seconds/60);lcd.print("m"); //print seconds if (time_seconds%60 < 10) lcd.print("0"); lcd.print(time_seconds%60);lcd.print("s "); //print seconds time_seconds++; } //---------------------------------------