#8 Design An LED Game [Post Homework Here]

Talk about the fourth PyroEDU course here.
ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

#8 Design An LED Game [Post Homework Here]

Postby ThePyroElectro » Thu May 01, 2014 7:14 pm

A new lesson was posted today:
http://www.pyroelectro.com/edu/microcontrollers/led_game/

Post your homework answers here to compare with everyone else!

little_cowboy
Newbie Pyro
Posts: 7
Joined: Mon Nov 04, 2013 12:32 am

Re: #8 Design An LED Game [Post Homework Here]

Postby little_cowboy » Wed May 21, 2014 2:20 am

1. The trimpot acts as a voltage divider varying the voltage going to A0 from 0 to 5 volts, which A0 translates to a value between 0 and 1023. This value is divided by 4 to obtain a milliseconds value which is used as an argument in the delay function, timing the transition between LEDs.

2. The 4026 acts as a one digit counter/led segment driver. When pin 1 (clock) of the 4026 receives a pulse from pin D13 of the Atmel chip, it increments the count by 1.

3. The 10K resistor and the .1 ufd cap go from D3 to +5v instead of ground, leaving D3 high. The other leg of the pushbutton goes to ground instead of +5v so that when the button is pressed, D3 makes a transition from high to low, hence falling/

You also need to change the program line to:

attachInterrupt(1, winner_check, FALLING);

I thought this was a great lesson. Just for fun, I added a Serial.begin(9600); line to the setup section and in the main logic loop inserted Serial.println(analogRead(a0)); and Serialprintln(adc_val); lines so that I could turn on the serial monitor in the Arduino program editor and see the values change as I adjusted the trimpot while the program was running.

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Re: #8 Design An LED Game [Post Homework Here]

Postby ThePyroElectro » Fri May 30, 2014 5:09 pm

little_cowboy wrote:You also need to change the program line to:

attachInterrupt(1, winner_check, FALLING);

I thought this was a great lesson. Just for fun, I added a Serial.begin(9600); line to the setup section and in the main logic loop inserted Serial.println(analogRead(a0)); and Serialprintln(adc_val); lines so that I could turn on the serial monitor in the Arduino program editor and see the values change as I adjusted the trimpot while the program was running.


Good answers!

The RISING/FALLING edge of the interrupt shouldn't technically matter since a button press will create both a falling and rising edge transition.

Nice addition to the program. I'm glad you liked the lesson!


Return to “Introduction to Microcontrollers”

Who is online

Users browsing this forum: No registered users and 3 guests