Team 1672 Mahwah Day Arena Schematic
Below is the electronics board I designed for my robotics team at a town festival we attended. It basically counted down from 120 seconds and implemented different strobe patterns upon reaching different time intervals. At 90 seconds the time remaining appears on the two 7 segment displays.
Here is the code that was loaded onto the ATMEGA88P by a AVRISPMKII
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | /** * Written by Brent Strysko for Team 1672 * http://www.brentstrysko.com * http://www.team1672.com * All Rights Reserved * * PC5 - Relay 1 * PC4 - Relay 2 * PC3 - Relay 3 * PC2 - Relay 4 * * PB0 - 7 Segment 1 A * PB1 - 7 Segment 1 B * PB2 - 7 Segment 1 C * PB3 - 7 Segment 1 D * * PB4 - 7 Segment 2 A * PB5 - 7 Segment 2 B * PB6 - 7 Segment 2 C * PB7 - 7 Segment 2 D */ #define F_CPU 1000000 #include <avr/io.h> #include <util/delay.h> //update 7 Segment displays in respect to the time void updateClock(unsigned char timeRemaining) { unsigned char digitH = timeRemaining / 10; unsigned char digitL = timeRemaining % 10; PORTB = (digitH << 4) | (digitL); } //update relays in respect to the time void updateRelays(unsigned char timeRemaining) { if( (90 < timeRemaining) && (timeRemaining <= 120)) //lights strobe to the left { if(PORTC & 0x04) //if it reached the lowest pin(Pin 2) { PORTC = (1 << PC5); //turn highest pin on } else { unsigned char temp = PORTC; PORTC = temp >> 1; //turn pin off and the one lower on } } else if(timeRemaining == 90) { PORTC = 1 << PC2; } else if((30 < timeRemaining) && (timeRemaining < 90)) //lights strobe to the right { if(PORTC & 0x20) //if it reached the highest pin(Pin 5) { PORTC = (1 << PC2); //turn low pin on } else { unsigned char temp = PORTC; PORTC = temp << 1; //turn one pin off and the one higher on } } else if(timeRemaining == 30) { PORTC = 0xFF; //turn all pins on } else { PORTC = ~PORTC; //strobe the pins } } int main(void) { //make pins on PORTS B and C outputs DDRB = (1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3) | (1 << DDB4) | (1 << DDB5) | (1 << DDB6) | (1 << DDB7); DDRC = (1 << DDC2) | (1 << DDC3) | (1 << DDC4) | (1 << DDC5); PORTC = (1 << PC5); PORTB = 0xAA; unsigned char timeRemaining = 120; unsigned char counter = 0; while(1) { while(counter < 25) { if(counter == 24) { updateRelays(timeRemaining); } if(timeRemaining <= 90) { updateClock(timeRemaining); } _delay_ms(40); counter++; } timeRemaining--; counter = 0; if(timeRemaining == 0) { updateClock(0); return 0; } } return 0; } |