Created
March 22, 2015 21:02
-
-
Save bofh/a10bf0152ec6253574db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ledState = 0; | |
int laserState = 0; | |
long prevTime = 0; | |
void setup() | |
{ | |
// laser on A0 | |
pinMode(A0, OUTPUT); | |
digitalWrite(A0, LOW); | |
// use D2 as power supply for phototransistor | |
pinMode(2, OUTPUT); | |
digitalWrite(2, HIGH); | |
// Phototransistor on D3 | |
attachInterrupt(1, blink, CHANGE); | |
// onboard LED for receiver debug | |
pinMode(13, OUTPUT); | |
} | |
void loop() | |
{ | |
unsigned long now = millis(); | |
if (now - prevTime > 500) { | |
prevTime = now; | |
laserState = !laserState; // just blink it for now | |
} | |
digitalWrite(A0, laserState); | |
digitalWrite(13, ledState); // onboard LED | |
} | |
void blink() | |
{ | |
ledState = !ledState; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment