Advertisement
pacozaa

yoak-arduino-adc

Nov 27th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. void setup() {
  2. // initialize serial communication at 9600 bits per second:
  3. delay(5000);
  4. Serial.begin(9600);
  5. }
  6.  
  7. // the loop routine runs over and over again forever:
  8. void loop() {
  9. // read the input on analog pin 0:
  10. int sensorValue = analogRead(A0);
  11. // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  12. float voltage = sensorValue * (5.0 / 1023.0);
  13. // print out the value you read:
  14. Serial.print("Voltage : ");
  15. Serial.print(voltage);
  16. Serial.println(" V ");
  17. delay(1000);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement