We first built the LDR circuit that we previously built with a 10K resistor and connecting to analog pin 0 of the Arduino. We then coded the Arduino to allow us to use the serial debug.
We can also code the Arduino such that it will read whatever we want it to read in the serial debug screen. We changed the code to read "The Sensor reading is" and "ADC counts" by adding it to the code with the Serial.print command.
We then practiced using keyboard inputs to trigger the Arduino. We initialized the serial port again and coded "inChar" into the Arduino which stands for a character or small integer. After opening the serial monitor and typing numbers and letters, the serial monitor responded with the appropriate response. The entered characters will get a response based on either dec, hex or binary as specified by the code.
You can see the responses we got in the serial monitor after typing in different characters, numbers and letters.
Next we coded the Arduino to turn a pin on or off based on characters typed into the keyboard. We used the command: "char inChar = (char)Serial.read();
Lab 10 finished!
No comments:
Post a Comment