280
edits
No edit summary |
Xuanngoc1992 (talk | contribs) |
||
Line 68: | Line 68: | ||
|code= | |code= | ||
<syntaxhighlight> | <syntaxhighlight> | ||
/* | |||
How the code work: | |||
- Read ADC value (0->1023) from pin A1 => Display on Serial Monitor with Baudrate speed 9600. | |||
*/ | |||
int analogPin = A1; // Declare input ADC pin | |||
void setup() { | void setup(){ | ||
Serial.begin(9600); | |||
Serial.println("MakerLab.vn Demo Read Analog Sensor"); | |||
} | } | ||
void loop() { | void loop(){ | ||
/ | // Read value (0->1023) from analogPin (A1) | ||
int sensorValue = analogRead(analogPin); | |||
// Display value on Serial Monitor | |||
Serial.println(sensorValue); | |||
delay(100); // Wait 100ms then repeat | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
==Kết quả== | ==Kết quả== | ||
{{kxndone | {{kxndone |