Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Interactive RGB Led Table Test Program
void Interactive_Table()
{
if ( (unsigned long) (micros() - samplingtime) > 200 ) // Read 8 phototransistors every 200us
{
// Read 8 phototransistors every 200us and store data into array
phototransistor_data[0 + photo_adder] = analogRead(A0);
phototransistor_data[8 + photo_adder] = analogRead(A1);
phototransistor_data[16 + photo_adder] = analogRead(A2);
phototransistor_data[24 + photo_adder] = analogRead(A3);
phototransistor_data[32 + photo_adder] = analogRead(A4);
phototransistor_data[40 + photo_adder] = analogRead(A5);
phototransistor_data[48 + photo_adder] = analogRead(A6);
phototransistor_data[56 + photo_adder] = analogRead(A7);
// update sensor group and mux selects for next time through
if (photo_adder < 7 )
{
photo_adder ++;
}
else
{
photo_adder = 0;
}
digitalWrite(Select1, bitRead(photo_adder, 2)); // sense mux MSB
digitalWrite(Select2, bitRead(photo_adder, 1));
digitalWrite(Select3, bitRead(photo_adder, 0)); // sense mux LSB
samplingtime = micros();
}
for (byte i=0; i<64; i++)
{
if (phototransistor_data[i] < LimitSense)
{
ClearLightZone(i); // clear color
}
else
{
SetLightZone(i, 15, 0, 0); // set RED color
}
}
}
void SetLightZone(byte Zone, byte R, byte G, byte B)
{
switch (Zone)
{
case 0: DrawLight(Zone00, R, G, B); break;
case 1: DrawLight(Zone01, R, G, B); break;
case 2: DrawLight(Zone02, R, G, B); break;
case 3: DrawLight(Zone03, R, G, B); break;
case 4: DrawLight(Zone04, R, G, B); break;
case 5: DrawLight(Zone05, R, G, B); break;
case 6: DrawLight(Zone06, R, G, B); break;
case 7: DrawLight(Zone07, R, G, B); break;
case 8: DrawLight(Zone08, R, G, B); break;
case 9: DrawLight(Zone09, R, G, B); break;
case 10: DrawLight(Zone10, R, G, B); break;
case 11: DrawLight(Zone11, R, G, B); break;
case 12: DrawLight(Zone12, R, G, B); break;
case 13: DrawLight(Zone13, R, G, B); break;
case 14: DrawLight(Zone14, R, G, B); break;
case 15: DrawLight(Zone15, R, G, B); break;
case 16: DrawLight(Zone16, R, G, B); break;
case 17: DrawLight(Zone17, R, G, B); break;
case 18: DrawLight(Zone18, R, G, B); break;
case 19: DrawLight(Zone19, R, G, B); break;
case 20: DrawLight(Zone20, R, G, B); break;
case 21: DrawLight(Zone21, R, G, B); break;
case 22: DrawLight(Zone22, R, G, B); break;
case 23: DrawLight(Zone23, R, G, B); break;
case 24: DrawLight(Zone24, R, G, B); break;
case 25: DrawLight(Zone25, R, G, B); break;
case 26: DrawLight(Zone26, R, G, B); break;
case 27: DrawLight(Zone27, R, G, B); break;
case 28: DrawLight(Zone28, R, G, B); break;
case 29: DrawLight(Zone29, R, G, B); break;
case 30: DrawLight(Zone30, R, G, B); break;
case 31: DrawLight(Zone31, R, G, B); break;
case 32: DrawLight(Zone32, R, G, B); break;
case 33: DrawLight(Zone33, R, G, B); break;
case 34: DrawLight(Zone34, R, G, B); break;
case 35: DrawLight(Zone35, R, G, B); break;
case 36: DrawLight(Zone36, R, G, B); break;
case 37: DrawLight(Zone37, R, G, B); break;
case 38: DrawLight(Zone38, R, G, B); break;
case 39: DrawLight(Zone39, R, G, B); break;
case 40: DrawLight(Zone40, R, G, B); break;
case 41: DrawLight(Zone41, R, G, B); break;
case 42: DrawLight(Zone42, R, G, B); break;
case 43: DrawLight(Zone43, R, G, B); break;
case 44: DrawLight(Zone44, R, G, B); break;
case 45: DrawLight(Zone45, R, G, B); break;
case 46: DrawLight(Zone46, R, G, B); break;
case 47: DrawLight(Zone47, R, G, B); break;
case 48: DrawLight(Zone48, R, G, B); break;
case 49: DrawLight(Zone49, R, G, B); break;
case 50: DrawLight(Zone50, R, G, B); break;
case 51: DrawLight(Zone51, R, G, B); break;
case 52: DrawLight(Zone52, R, G, B); break;
case 53: DrawLight(Zone53, R, G, B); break;
case 54: DrawLight(Zone54, R, G, B); break;
case 55: DrawLight(Zone55, R, G, B); break;
case 56: DrawLight(Zone56, R, G, B); break;
case 57: DrawLight(Zone57, R, G, B); break;
case 58: DrawLight(Zone58, R, G, B); break;
case 59: DrawLight(Zone59, R, G, B); break;
case 60: DrawLight(Zone60, R, G, B); break;
case 61: DrawLight(Zone61, R, G, B); break;
case 62: DrawLight(Zone62, R, G, B); break;
case 63: DrawLight(Zone63, R, G, B); break;
}
}
void ClearLightZone(byte Zone)
{
switch (Zone)
{
case 0: DrawLight(Zone00, 0, 0, 0); break;
case 1: DrawLight(Zone01, 0, 0, 0); break;
case 2: DrawLight(Zone02, 0, 0, 0); break;
case 3: DrawLight(Zone03, 0, 0, 0); break;
case 4: DrawLight(Zone04, 0, 0, 0); break;
case 5: DrawLight(Zone05, 0, 0, 0); break;
case 6: DrawLight(Zone06, 0, 0, 0); break;
case 7: DrawLight(Zone07, 0, 0, 0); break;
case 8: DrawLight(Zone08, 0, 0, 0); break;
case 9: DrawLight(Zone09, 0, 0, 0); break;
case 10: DrawLight(Zone10, 0, 0, 0); break;
case 11: DrawLight(Zone11, 0, 0, 0); break;
case 12: DrawLight(Zone12, 0, 0, 0); break;
case 13: DrawLight(Zone13, 0, 0, 0); break;
case 14: DrawLight(Zone14, 0, 0, 0); break;
case 15: DrawLight(Zone15, 0, 0, 0); break;
case 16: DrawLight(Zone16, 0, 0, 0); break;
case 17: DrawLight(Zone17, 0, 0, 0); break;
case 18: DrawLight(Zone18, 0, 0, 0); break;
case 19: DrawLight(Zone19, 0, 0, 0); break;
case 20: DrawLight(Zone20, 0, 0, 0); break;
case 21: DrawLight(Zone21, 0, 0, 0); break;
case 22: DrawLight(Zone22, 0, 0, 0); break;
case 23: DrawLight(Zone23, 0, 0, 0); break;
case 24: DrawLight(Zone24, 0, 0, 0); break;
case 25: DrawLight(Zone25, 0, 0, 0); break;
case 26: DrawLight(Zone26, 0, 0, 0); break;
case 27: DrawLight(Zone27, 0, 0, 0); break;
case 28: DrawLight(Zone28, 0, 0, 0); break;
case 29: DrawLight(Zone29, 0, 0, 0); break;
case 30: DrawLight(Zone30, 0, 0, 0); break;
case 31: DrawLight(Zone31, 0, 0, 0); break;
case 32: DrawLight(Zone32, 0, 0, 0); break;
case 33: DrawLight(Zone33, 0, 0, 0); break;
case 34: DrawLight(Zone34, 0, 0, 0); break;
case 35: DrawLight(Zone35, 0, 0, 0); break;
case 36: DrawLight(Zone36, 0, 0, 0); break;
case 37: DrawLight(Zone37, 0, 0, 0); break;
case 38: DrawLight(Zone38, 0, 0, 0); break;
case 39: DrawLight(Zone39, 0, 0, 0); break;
case 40: DrawLight(Zone40, 0, 0, 0); break;
case 41: DrawLight(Zone41, 0, 0, 0); break;
case 42: DrawLight(Zone42, 0, 0, 0); break;
case 43: DrawLight(Zone43, 0, 0, 0); break;
case 44: DrawLight(Zone44, 0, 0, 0); break;
case 45: DrawLight(Zone45, 0, 0, 0); break;
case 46: DrawLight(Zone46, 0, 0, 0); break;
case 47: DrawLight(Zone47, 0, 0, 0); break;
case 48: DrawLight(Zone48, 0, 0, 0); break;
case 49: DrawLight(Zone49, 0, 0, 0); break;
case 50: DrawLight(Zone50, 0, 0, 0); break;
case 51: DrawLight(Zone51, 0, 0, 0); break;
case 52: DrawLight(Zone52, 0, 0, 0); break;
case 53: DrawLight(Zone53, 0, 0, 0); break;
case 54: DrawLight(Zone54, 0, 0, 0); break;
case 55: DrawLight(Zone55, 0, 0, 0); break;
case 56: DrawLight(Zone56, 0, 0, 0); break;
case 57: DrawLight(Zone57, 0, 0, 0); break;
case 58: DrawLight(Zone58, 0, 0, 0); break;
case 59: DrawLight(Zone59, 0, 0, 0); break;
case 60: DrawLight(Zone60, 0, 0, 0); break;
case 61: DrawLight(Zone61, 0, 0, 0); break;
case 62: DrawLight(Zone62, 0, 0, 0); break;
case 63: DrawLight(Zone63, 0, 0, 0); break;
}
}
void DrawLight(byte zone_dots[4][2], byte R, byte G, byte B)
{
for (int i = 0; i < 4; i++)
{
LED(zone_dots[i][0], zone_dots[i][1], R, G, B);
//delay_ms(10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.