diff options
Diffstat (limited to 'CODE/debug/IR')
| -rw-r--r-- | CODE/debug/IR/IR_sens/IR_sens.ino | 149 | ||||
| -rw-r--r-- | CODE/debug/IR/communication/direct_rx/direct_rx.ino | 15 | ||||
| -rw-r--r-- | CODE/debug/IR/communication/rx_teensy/rx_teensy.ino | 35 | ||||
| -rw-r--r-- | CODE/debug/IR/communication/tx_seeed/tx_seeed.ino | 29 | ||||
| -rw-r--r-- | CODE/debug/IR/teensydeco/teensydeco.ino | 104 |
5 files changed, 0 insertions, 332 deletions
diff --git a/CODE/debug/IR/IR_sens/IR_sens.ino b/CODE/debug/IR/IR_sens/IR_sens.ino deleted file mode 100644 index 85089d4..0000000 --- a/CODE/debug/IR/IR_sens/IR_sens.ino +++ /dev/null @@ -1,149 +0,0 @@ -int ir1 = 0; -int ir2 = 1; -int ir3 = 9; -int ir4 = 2; -int ir5 = 3; -int ir6 = 4; -int ir7 = 5; -int ir8 = 8; - -int dir1 = 1; // data IR1 -int dir2 = 1; // data IR2 -int dir3 = 1; // etc -int dir4 = 1; -int dir5 = 1; -int dir6 = 1; -int dir7 = 1; -int dir8 = 1; - -volatile long IRcount1 = 0; -volatile long IRcount2 = 0; -volatile long IRcount3 = 0; -volatile long IRcount4 = 0; -volatile long IRcount5 = 0; -volatile long IRcount6 = 0; -volatile long IRcount7 = 0; -volatile long IRcount8 = 0; - -void setup() { - pinMode(ir1, INPUT); - pinMode(ir2, INPUT); - pinMode(ir3, INPUT); - pinMode(ir4, INPUT); - pinMode(ir5, INPUT); - pinMode(ir6, INPUT); - pinMode(ir7, INPUT); - pinMode(ir8, INPUT); - - Serial.begin(9600); - Serial1.begin(9600); - Serial.println("start"); - Serial1.println("start"); - - attachInterrupt(digitalPinToInterrupt(ir1), IRtrigger1, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir2), IRtrigger2, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir3), IRtrigger3, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir4), IRtrigger4, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir5), IRtrigger5, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir6), IRtrigger6, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir7), IRtrigger7, CHANGE); - attachInterrupt(digitalPinToInterrupt(ir8), IRtrigger8, CHANGE); - - Serial.println("Starting loop"); - Serial1.println("Starting loop"); -} - -void IRtrigger1() { - IRcount1++; -} -void IRtrigger2() { - IRcount2++; -} -void IRtrigger3() { - IRcount3++; -} -void IRtrigger4() { - IRcount4++; -} -void IRtrigger5() { - IRcount5++; -} -void IRtrigger6() { - IRcount6++; -} -void IRtrigger7() { - IRcount7++; -} -void IRtrigger8() { - IRcount8++; -} - -void loop() { - Serial.print("ir 1 changes: "); - Serial.print(IRcount1); - Serial.print(", ir 2 changes: "); - Serial.print(IRcount2); - Serial.print(", ir 3 changes: "); - Serial.print(IRcount3); - Serial.print(", ir 4 changes: "); - Serial.print(IRcount4); - Serial.print(", ir 5 changes: "); - Serial.print(IRcount5); - Serial.print(", ir 6 changes: "); - Serial.print(IRcount6); - Serial.print(", ir 7 changes: "); - Serial.print(IRcount7); - Serial.print(", ir 8 changes: "); - Serial.println(IRcount8); - - Serial1.print("ir 1 changes: "); - Serial1.print(IRcount1); - Serial1.print(", ir 2 changes: "); - Serial1.print(IRcount2); - Serial1.print(", ir 3 changes: "); - Serial1.print(IRcount3); - Serial1.print(", ir 4 changes: "); - Serial1.print(IRcount4); - Serial1.print(", ir 5 changes: "); - Serial1.print(IRcount5); - Serial1.print(", ir 6 changes: "); - Serial1.print(IRcount6); - Serial1.print(", ir 7 changes: "); - Serial1.print(IRcount7); - Serial1.print(", ir 8 changes: "); - Serial1.print(IRcount8); - - volatile long IRcounts[] = {IRcount1, IRcount2, IRcount3, IRcount4, IRcount5, IRcount6, IRcount7, IRcount8}; - long maxCount = IRcounts[0]; - int highessensor = 1; - for (int i = 0; i < 7; ++i) { - if (IRcounts[i] > maxCount) { - maxCount = IRcounts[i]; - highessensor = i + 1; - } - } - Serial.print("Ball is at sensor: "); - Serial.print(highessensor); - Serial.print(", with value of "); - Serial.println(maxCount); - - Serial1.print("s"); - Serial1.print(highessensor); - Serial1.print(", "); - Serial1.println(maxCount); - Serial1.print("e"); - - IRcount1 = 0; - IRcount2 = 0; - IRcount3 = 0; - IRcount4 = 0; - IRcount5 = 0; - IRcount6 = 0; - IRcount7 = 0; - IRcount8 = 0; - - - - delay(250); - -} diff --git a/CODE/debug/IR/communication/direct_rx/direct_rx.ino b/CODE/debug/IR/communication/direct_rx/direct_rx.ino deleted file mode 100644 index 336b27b..0000000 --- a/CODE/debug/IR/communication/direct_rx/direct_rx.ino +++ /dev/null @@ -1,15 +0,0 @@ -int incomingbyte = 0; -void setup() { - Serial.begin(9600); - Serial2.begin(9600); //19200 - Serial3.begin(9600); //19200 - Serial.print("Starting ...."); -} - -void loop() { - if (Serial3.available() > 0) { - incomingbyte = Serial3.read(); - Serial.print(char(incomingbyte)); - } - -} diff --git a/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino b/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino deleted file mode 100644 index 68a768b..0000000 --- a/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino +++ /dev/null @@ -1,35 +0,0 @@ -int incomingbyte = 0; -bool iswriting = false; -String tlocdat = ""; //temporary location data -String locdat = ""; //location data -int nir = "-99"; // which ir sensor it is -int pir = "-99"; // amount of pulses it had -void setup() { - Serial.begin(9600); - Serial3.begin(9600); //19200 -} - -void loop() { - if (Serial3.available() > 0) { - incomingbyte = Serial3.read(); - //Serial.print(char(incomingbyte)); - if (incomingbyte == 's'){ - iswriting = true; - tlocdat = ""; - }else if(incomingbyte == 'e'){ - iswriting = false; - locdat = tlocdat; - }else if(iswriting == true){ - //Serial.print(char(incomingbyte)); - tlocdat += (char)incomingbyte; - } - } - //Serial.println(locdat); - sscanf(locdat.c_str(), "%d, %d", &nir, &pir); - Serial.print("IR sensor N: "); - Serial.print(nir); - Serial.print(", with "); - Serial.print(pir); - Serial.println(" pulses."); - delay(10); -} diff --git a/CODE/debug/IR/communication/tx_seeed/tx_seeed.ino b/CODE/debug/IR/communication/tx_seeed/tx_seeed.ino deleted file mode 100644 index dc2d2e9..0000000 --- a/CODE/debug/IR/communication/tx_seeed/tx_seeed.ino +++ /dev/null @@ -1,29 +0,0 @@ -long randNumber1; -long randNumber2; - -void setup() { - Serial.begin(9600); - Serial1.begin(9600); - delay(2500); - randomSeed(analogRead(0)); - -} - -void loop() { - randNumber1 = random(1000); - randNumber2 = random(1, 8); - Serial1.print("s"); - Serial1.print(randNumber2); - Serial1.print(", "); - Serial1.print(randNumber1); - Serial1.print("e"); - - Serial.print("s"); - Serial.print(randNumber2); - Serial.print(", "); - Serial.print(randNumber1); - Serial.println("e"); - delay(1000); - - -} diff --git a/CODE/debug/IR/teensydeco/teensydeco.ino b/CODE/debug/IR/teensydeco/teensydeco.ino deleted file mode 100644 index f8fe2a5..0000000 --- a/CODE/debug/IR/teensydeco/teensydeco.ino +++ /dev/null @@ -1,104 +0,0 @@ -int incomingbyte1 = 0; //the byte that it is reciefing -bool iswriting1 = false; //true if writing else fals -String tlocdat1 = ""; //temporary location data -String locdat1 = ""; //location data -int nir1 = "-99"; // which ir sensor it is -int pir1 = "-99"; // amount of pulses it had - -int incomingbyte2 = 0; //same but for seeed xiao N 2 -bool iswriting2 = false; -String tlocdat2 = ""; -String locdat2 = ""; -int nir2 = "-99"; -int pir2 = "-99"; - -float degwhere = -99.0; // where the ball is in degrees - -void setup() { - Serial.begin(9600); - Serial3.begin(9600); - Serial2.begin(9600); -} - -void loop() { - if (Serial3.available() > 0) { - incomingbyte1 = Serial3.read(); - //Serial.print(char(incomingbyte1)); - if (incomingbyte1 == 's'){ - iswriting1 = true; - tlocdat1 = ""; - }else if(incomingbyte1 == 'e'){ - iswriting1 = false; - locdat1 = tlocdat1; - }else if(iswriting1 == true){ - //Serial.print(char(incomingbyte1)); - tlocdat1 += (char)incomingbyte1; - } - } - if (Serial2.available() > 0) { - incomingbyte2 = Serial2.read(); - //Serial.print(char(incomingbyte2)); - if (incomingbyte2 == 's'){ - iswriting2 = true; - tlocdat2 = ""; - }else if(incomingbyte1 == 'e'){ - iswriting2 = false; - locdat2 = tlocdat1; - }else if(iswriting2 == true){ - //Serial.print(char(incomingbyte1)); - tlocdat2 += (char)incomingbyte1; - } - } - //Serial.println(locdat); - sscanf(locdat1.c_str(), "%d, %d", &nir1, &pir1); - sscanf(locdat2.c_str(), "%d, %d", &nir2, &pir2); - - - if(pir1 > pir2){ - if(nir1 = 1){ //not good looking code because posbile wrong wireing - degwhere = 0; - }else if(nir1 = 2){ - degwhere = 22.5; - }else if(nir1 = 3){ - degwhere = 45; - }else if(nir1 = 4){ - degwhere = 67.5; - }else if(nir1 = 5){ - degwhere = 90; - }else if(nir1 = 6){ - degwhere = 112.5; - }else if(nir1 = 7){ - degwhere = 135; - }else if(nir1 = 8){ - degwhere = 157.5; - } - }else{ - if(nir2 = 1){ - degwhere = 180; - }else if(nir2 = 2){ - degwhere = 202.5; - }else if(nir2 = 3){ - degwhere = 225; - }else if(nir2 = 4){ - degwhere = 247.5; - }else if(nir2 = 5){ - degwhere = 270; - }else if(nir2 = 6){ - degwhere = 292.5; - }else if(nir2 = 7){ - degwhere = 315; - }else if(nir2 = 8){ - degwhere = 337.5; - } - } - - Serial.print("IR sensor N: "); - Serial.print(nir1); - Serial.print(", with "); - Serial.print(pir1); - Serial.println(" pulses."); - Serial.print("That is "); - Serial.print(degwhere); - Serial.println(" degrees."); - delay(10); -} |
