Mission 9 - Understanding Data
DuinoKit Essentials - View Only. See new "Mission Manual" forum for manual and code   Started by Daniel Alich   2017-06-27 21:37:23 -04:00   Comments: 1    Viewed: 1025

1. ##### Daniel AlichMemberStaff Member `/*The LCD hookup was included in this script and uses the same hookup as the LCD tutorial (Lesson3) included for the DuinoKit.com project. Once hooking an analogue component/module to the A0 pin on the Arduino you will be able to view the output for this component in the serial  monitor on your computer. This will typically be a number from 1 to 1023. We will use programming to react to these vale changes from the component. In this sketch we also used the MAP function in the following line: MapValue=map(analog0,0,1023,1,10); // The Map function The function above read the A0pin, allows for a rank of 0 to 1023 and then  converves these values to 1 to 10. This is the second value being displayed in the serial monitor. */#include  //Enable this script for LCD display if desired// declare variables used in this scriptint i;int analog0;int MapValue;// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(12, 11, 5, 4, 3, 2);// LCD PinOut (RS, E, D4, D5, D6, D7)void setup(){ lcd.begin(16,2); Serial.begin(9600); // initialize the serial communications:}void loop(){ analog0=0; for(i=0; i < 20; i++) // Loop and read A0 value 20 times {  delay (10); // Slow things down a little for reading values analog0=analog0+analogRead(A0); } analog0=analog0/i; // Divide total reading sum buy i MapValue=map(analog0,0,1023,1,10); // The Map function Serial.print(analog0); Serial.print("t"); Serial.println(MapValue); lcd.clear(); lcd.setCursor(0, 0); lcd.print(analog0);  lcd.setCursor(5, 0); lcd.print(MapValue);  delay(10);}`
2017-06-27 21:37:23 -04:00