Created
June 24, 2012 22:16
-
-
Save mactabish/2985223 to your computer and use it in GitHub Desktop.
Wireless Target Identification - Arduino Transmitter Code
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 piezoPin = 0; | |
int piezoThreshold = 40; | |
int piezoVal = 0; | |
int array_of_dip[10]; | |
int id_of_sensor = 1; | |
void serial_print() | |
{ | |
Serial.print("<"); | |
Serial.print(id_of_sensor); | |
Serial.print(">"); | |
} | |
void identify() | |
{ | |
array_of_dip[1] = digitalRead(2); | |
array_of_dip[2] = digitalRead(3); | |
array_of_dip[3] = digitalRead(4); | |
array_of_dip[4] = digitalRead(5); | |
for(int i = 1; i <= 4; i++) | |
{ | |
if (array_of_dip[i] == 1) | |
id_of_sensor = i; | |
} | |
} | |
void setup() | |
{ | |
pinMode(2, INPUT); | |
pinMode(3, INPUT); | |
pinMode(4, INPUT); | |
pinMode(5, INPUT); | |
pinMode(13, OUTPUT); | |
Serial.begin(57600); | |
identify(); | |
} | |
void loop() | |
{ | |
piezoVal = analogRead(piezoPin); | |
if (piezoVal >= piezoThreshold) | |
serial_print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment