Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* YourDuino Electronic Brick Test:
- Single Track Reflective Sensor AB-010201
- terry@yourduino.com */
- /*-----( Declare Constants )-----*/
- #define SWITCHPIN 3
- #define LEDPIN 13 // The onboard LED
- /*-----( Declare Variables )-----*/
- int switch_state; /* Holds the last state of the switch */
- void setup() /*----( SETUP: RUNS ONCE )----*/
- {
- pinMode(LEDPIN, OUTPUT);
- }/*--(end setup )---*/
- void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
- // This module is ACTIVE LOW when a reflection is seen
- {
- switch_state = digitalRead(SWITCHPIN);
- if (switch_state == LOW)
- {
- digitalWrite(LEDPIN, HIGH);
- }
- else
- {
- digitalWrite(LEDPIN, LOW);
- }
- }/* --(end main loop )-- */
- /* ( THE END ) */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement