Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wireless Target Identification - Arduino Transmitter Code
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