Mission 9 - Understanding Data
 DuinoKit Jr. - View Only. See new "Mission Manual" forum for manual and code   Started by Daniel Alich   2017-06-27 18:26:38 -04:00   Comments: 1    Viewed: 1317

  1. Daniel Alich
    Daniel Alich Member Staff Member
    252_1498602346_Mission 9-1.jpg

    252_1498602334_Mission 9-2.jpg

    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 <LiquidCrystal.h> //Enable this script for LCD display if desired

    // declare variables used in this script
    int i;
    int analog0;
    int MapValue;

    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    // LCD PinOut (RS, E, D4, D5, D6, D7)
    void setup()
    Serial.begin(9600); // initialize the serial communications:

    void loop()

    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/i; // Divide total reading sum buy i
    MapValue=map(analog0,0,1023,1,10); // The Map function


    lcd.setCursor(0, 0);
    lcd.setCursor(5, 0);

    Daniel Alich, 2017-06-27 18:26:38 -04:00
  2. (You must log in or sign up to post here)

Report Post

Write your reason

Log in | Sign up
Terms & Conditions!