Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sensorState = 0;
- void setup()
- {
- pinMode(2, INPUT);
- pinMode(13, OUTPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- // read the state of the sensor/digital input
- sensorState = digitalRead(2);
- // check if sensor pin is HIGH. if it is, set the
- // BUZZER on.
- if (sensorState == HIGH) {
- digitalWrite(13, HIGH);
- Serial.println("Sensor activated!");
- } else {
- digitalWrite(13, LOW);
- }
- delay(10); // Delay a little bit to improve simulation performance
- }
Add Comment
Please, Sign In to add comment