Saturday, April 30, 2016

Arduino Chapter 1 - Read Analog from Serial device

 

This example will show you how does a serial device send signal to Arduino and how Arduino will track those signal then show it on the screen through Serial Monitor of Arduino IDE.


Requirements:
- Arduino or Genuino Board
- TCTR 5000 Sensor

Circuit:




Code:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin A0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}

 

No comments:
Write comments

Visitors