Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define STATUS_LED 13
- #define INPUT_PIN 4
- #define ANALOG_PIN A0
- void setup() {
- pinMode(INPUT_PIN, INPUT);
- pinMode(STATUS_LED, OUTPUT);
- Serial.begin(9600);
- }
- int i;
- float value, voltage;
- void loop() {
- if (digitalRead(INPUT_PIN) == LOW) {
- digitalWrite(STATUS_LED, LOW);
- for (i=0; i<10; i++) {
- value = (float)analogRead(ANALOG_PIN);
- voltage = (value / 1023.0) * 5.0;
- Serial.println(voltage);
- delay(1000);
- }
- }
- digitalWrite(STATUS_LED, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement