Introduction: Infrared Quiz Buzzer ( Wireless )
Hey folks!
Get ready to explore the nook and corner of the IR signals and flaunt the Arduino codes. IR buzzer uses a circuit similar to that of a TV remote(Break open the remote and have a look!). We have a transmitter and a receiver section. The means of communication between them is Pulse Width Modulated(PWM) IR signals. The ATtiny is programmed to give PWM signals.When the buzzer button is pressed,voltage is applied to the ATTiny. An IR LED connected to it will emit the IR signal.This will be captured by the receiver.(As simple as that).
The whole model is Wireless -this helps overcome the problems of using wire, thus minimizing maintenance cost and chances of errors.It has multiple functionality- the system will not only indicate the first press of the buzzer but also the sequence in which the remaining teams press the buzzer.It is economical,flexible, easy to use, reliable and yes Robust!
Components:
- Push Buttons/Remotes
- An ATtiny85 microcontroller
- Battey-5V
- An IR LED
- STK500/Any programmer
- Jumper wires
- An Arduino board (or any controller with RAM space more than 20kb)
- An IR receiver module
- A 7 segment LED display .
- Resistors-100 ohms
- 8Mhz crystal oscillator
- A piezo buzzer
Step 1: Download Softwares and Install Them
You will need to download the following softwares and install them before you get started.
- ARDUINO IDE
- AVRDUDE
- ATTiny libraries
ARDUINO IDE
Arduino is an open source software and can be downloaded for free. Download it if you haven't already.
Download Arduino 1.6.x software:http://www.arduino.cc/en/Main/Software
Following the instructions,install it and get familiar with using the IDE.
ATTiny libraries
NOTE:you can omit this if you will be using the 8 transmitter codes we have uploaded.But you will have to do it if you want to experiment with the IR signals.
Download the corresponding ATiny zip file attached.
- Unzip the attiny zip file. It should contain an “attiny-ide.1.6.x” folder that contains an “attiny” folder.
- Locate your Arduino sketchbook folder (you can find its location in the preferences dialogue in the Arduino software)
- Create a new sub-folder called “hardware” in the sketchbook folder, if it doesn’t exist already.
- Copy the “attiny” folder from the unzipped ATtiny.zip to the “hardware” folder. You should end up with folder structure likeDocuments > Arduino > hardware > attiny > avr that contains the file boards.txt and another folder called variants.
- Restart the Arduino development environment.
- You should see an ATtiny entry in the Tools > Board menu. When you select it, you should see additional Clock and Processor sub-menus in the Tools menu. These allow you to specify your ATtiny configuration.In our case ATtiny85 working at 8Mhz clock frequency.
You can visit the arduino website to download the arduino software version of your choice.
AVRDUDE is a command line tool. So you will have to use command prompt. You must get familiar with the cmd commands. If you are not comfortable with cmd, you can always switch to GUI softwares that available for AVRDUDE. There are a many softwares available online.
Referring this website will help you get familiar with using AVRDUDE.
Attachments
Step 2: Make a Remote (or Buy One)
Note: If you don’t want to build a remote, small remotes are available for really cheap prices.Those who will buy remotes can skip this and jump to the 4th step.
Those who are going to use the hex files we provide can skip to the 3rd step.
Just read the next paragraph for a little understanding.
Let’s begin with an explanation of the signal we are going to send. We will transmit PWM (pulse width modulated) IR signal. There is no reason to be worried if you don’t know what that is. The IR signal will be pulsed on and off every 26 micro seconds (i.e., on for 13 and off for 13 or we can say the frequency is 38khz). Then this pulsed signal will be transmitted for some time (600 to 1500 micro seconds) and switched off (again about 600-1500 micro seconds). Turning this pulsed signal on and off should be repeated to get a string of on-off cycles. Vary the length of the on and off time to obtain different values .See this link to understand better.
https://learn.adafruit.com/ir-sensor/ir-remote-sig...
It’s simple, isn’t it?
Steps to make a remote:
- Upload the given program to attiny85 (needs library files as indicated in first step and a programmer)
- Extract the hex file
- Copy and paste
Connect the circuit
UPLOAD the program given below into arduino IDE after selecting the corresponding boards from tools menu and store it as sendIR.Change values in the brackets, next to the stars if you want to obtain your OWN codes. Experiment with SendUpCode function if you want different values.(You'd know what I'm talking about if you read till the end and tried uploading a program once into the attiny85 )
int IRledPin = 2; // LED connected to seventh pin in attiny85, if connecting just one // or change 2 to 0 in the above line and connect LED to fifth pin to connect //multiple LED like in circuit diagram //there is no mistake in the above two comments // The setup() method runs once, when the sketch starts void setup() { // initialize the IR digital pin as an output: pinMode(IRledPin, OUTPUT); // there will be no Serial.begin(9600) } void loop() { SendUpCode(); delay(1000); // wait one second } // This procedure sends a 38KHz pulse to the IRledPin // for a certain # of microseconds. We'll use this whenever we need to send codes void pulseIR(long microsecs) { // we'll count down from the number of microseconds we are told to wait cli(); // this turns off any background interrupts while (microsecs > 0) { // 38 kHz is about 13 microseconds high and 13 microseconds low digitalWrite(IRledPin,LOW); // this takes about 3 microseconds to happen delayMicroseconds(10); // hang out for 10 microseconds, you can also //change this to 9 if its not working digitalWrite(IRledPin,HIGH); // this also takes about 3 microseconds delayMicroseconds(10); // hang out for 10 microseconds, you //can also change this to 9 if its not working // so 26 microseconds altogether microsecs -= 26; } sei(); // this turns the interrupts them back on } void SendUpCode() { // Change values according to what you want, where ever there are stars //remove the stars after you are done //you could try increasing the number of pulseIR() and delayMicroseconds() functions //...to play around and see the results pulseIR(2080*); delay(27)// wait 27 milliseconds pulseIR(440*); delayMicroseconds(400*); pulseIR(460*); delayMicroseconds(440*); pulseIR(500*); delayMicroseconds(440*); pulseIR(200*); delayMicroseonds(627*); pulseIR(440*); delayMicroseconds(850*); pulseIR(460*); delayMicroseconds(344*); pulseIR(480*); }
Now we have to obtain hex code to use in AVRdude (for STK500v2).
EXTRACTING the hex file from arduino IDE is easy.First
Open arduino IDE => file => preferences => check show verbose during compilation.
Then compile the above programs with your modifications. You'd get lots of new words in the black space below the workspace in the IDE. The line just before the line indicating the number of bytes of the program is what you should copy. It has the path to the build folder containing the hex file.
C:\Users\PREMKU-1\AppData\Local\Temp\build3226901792308428727.tmp\sendIR.cpp.hex Binary sketch size: 658 bytes (of a 8192 byte maximum)
COPY and paste the path in 'My Computer'. There will be a file like 'sendIR.cpp.hex'. Yup, copy that and paste it somewhere safe after renaming it as 'sendIR.hex'. This is what we'll use in the next step.
CONNECT the circuit diagram as shown with single LED to test the IR transmitting codes.Later on you could connect the circuit with multiple LED for a full fledged remote.
Step 3: Programming ATTiny85 Using AVR Programmer
The ATtiny85 microcontroller is programmed using any AVR programmer. Programmer is a device which when connected to the chip to be programmed, allows the software on the computer to talk to the chip. All you have to do is connect the programmer to the chip and then give appropriate commands. The programmer will verify the device signature and transfer the program in hex format into the flash memory of the chip.
There are many AVR programmers that are supported by AVRDUDE. These include Atmel AVR ISP, Atmel AVR ISP mkII, Atmel AVR ISP mkII, Atmel AVR ISP V2, Atmel JTAG ICE mkII etc., and any of them can be used.
We will be using STK500v2, as the programmer.
Note: Every AVR has a set of pins that are used as programming pins. It is important that you look into the datasheets for correct pins if you are using other AVR chips.
The STK500v2 will be used in HID mode with AVRDUDE as the programming interface. So insert jumper2 in the slot. Jumper1 is inserted to enable the power supply to the programmer via the USB connected to the computer. Refer the manual uploaded to locate the jumper slots.
The STK500v2 ISP header pins are connected to the corresponding pins of ATTiny85 like this:
ISP header -->ATtiny85
VTG -->VCC(pin8)
MOSI -->MOSI(pin 5)
Reset -->Reset(pin1)
SCK -->SCK(Pin7)
MISO -->MISO(pin6)
Ground(pin4) -->Ground(pin4)
Also connect an 8MHz crystal oscillator between pins 2 and 3 of the ATtiny85.
Just in case you want to experiment with the STK500v2, the manual is uploaded as well.
Here is how you use AVRDUDE. The 'DUDE' as we call it :P
Install the AVRDUDE software to supply the programmer with the necessary commands to get it functioning. Once this is done, open the command prompt and change directory to the directory where AVRDUDE is installed. Make sure that the hex file of the program to be uploaded into the controller is in the AVRDUDE folder. Then type in the following command and hit enter.
avrdude -c stk500v2 -p attiny85 -P NEX-USB-ISP -U flash:w:sendIR.hex -U efuse:w:0xff:m -U hfuse:w:0xdf:m -U lfuse:w:0xfe:m
The programmer verifies the device signature, the fuse bits and writes the program into the flash memory of the controller in a few seconds.Now the ATtiny85 is ready to send IR signal.Connect an IR led between pins 7 and 8 through a 100 ohm resistor and watch it send a specific IR signal.You will not be able to see IR signals through naked eyes. Use you phone camera!
The circuit can be modified to a remote by soldering the IR led and the crystal oscillator to the corresponding pins of the ATtiny85 and powering it with a 5V battery through a push button.
Refer this link if you want to experiment with AVRDUDE
http://www.ladyada.net/learn/avr/avrdude.html
NOTE: The fuse bits for Attiny85 are configured to use external 8 MHz crystal oscillator. They will be different for different frequencies of operation and different microcontrollers. One needs to check up the datasheets and change appropriately.
Eight hex codes are uploaded to program eight ATtiny85 microcontrollers to produce eight unique IR signals one for each team!.
Step 4: Use IR Receiver
Steps to be followed:
- Download IR library folder
- Put IR library folder in arduino IDE
- Upload code
- Connect the IR receiver
DOWNLOAD Ir library file from github website. Link given below
https://github.com/shirriff/Arduino-IRremote
PUT the IRremote folder in ‘libraries’ folder. You can find the location of arduino folder by
File => Preferences
In the little box, there will a path to the folder where you sketch is being stored. Most probably the libraries folder will be there. If not, search for it like we did :P.
UPLOAD the program given below , compile and store it somewhere safe. This sketch called final will be used during the working of the buzzer. There will be no problems here as it's really simple.Any doubts regarding the IR library will be addressed and explained in the link given below:
http://www.righto.com/2009/08/multi-protocol-infra...
Read it well :)
CONNECT the IR receiver as shown in the circuit diagram. What we used is TSOP1738. There are other models. See the pin diagram for them and connect the pins respectively. The output pin is pin 11 or any PWM pin in your board. Don't forget to change it in your sketch if you are using a different pin.
Attachments
Step 5: Obtaining Remote Button Values
We’ll be obtaining the IR values sent by the remote and putting it up in the final buzzer program.
Steps to be followed:
- Upload the program
- Obtain the values of IR signals
- Copy and paste
UPLOAD the code given called IRcheck to your arduino board. Open the serial monitor to the port connected to the board.
OBTAIN the values emitted by remote. Take the remote. Point it at the receiver and press the button. Some secimal values are obtained (eg: 33423615). There will be a value that repeats every time you press the button, this value should be copied and stored.You can get values less than 8 decimal digits depending on the code or remote. Press different remote buttons corresponding to the different teams and store these values separately. If you are writing your own code, change the code every time to get different values and store it. If you are going to use the hex files we provided then first upload it to the attiny. Then connect the circuit with one led as shown in this instructable. Point the LED at the receiver and obtain the decimal IR values for all the hex files.
COPY each value from the stored location into the final buzzer program. Where? In the Loop function, the first while loop will have a line like
if((results.value)==33423615&&check[1]==0)
Replace ‘33423615’ with the value you stored. There you go, your first team is recognised as team one. Replace all other values in the same loop with your hex values for team 2, 3, 4, etc. Feel free to experiment with the delays and other parts after all the original is here. You should be able to see the code work without a seven segment display. Just run the code and open Serial monitor. :)
Note: in the final buzz there is a pin allocated for attaching a buzzer as well. Connect the longer lead to this pin and the shorter lead to ground. The buzzer will sound every time any team presses their remote button fo the first time in every round.
.
Attachments
Step 6: Interfacing 7-segment Led Display
The 7-segment display consists of 7 LEDs labelled from A,B……G. This unit, interfaced to the
microcontroller is programmed so as to turn ON the appropriate LEDs corresponding to the 1st team that pressed their remote buttons. The explanation for display is put up in the link below:
https://www.instructables.com/id/Seven-Segment-Disp...
There are 2 types of Led display-Common Cathode and Common Anode.Refer the link below and learn more about it.
Please note that you use a current limiting resistor of around 330 Ohms to avoid burning the display.
http://www.electronics-tutorials.ws/blog/7-segment...
For common cathode,reverse the 0’s and 1’s in the code and connect the ‘common’ pin to ground instead of Vcc.
Once arduino is coded then when push buttons corresponding to the teams are pressed,the subsequent team numbers are also displayed.The buzzer turns on every time the IR receiver recognizes that a team has pressed their remote button. This buzzer can display even the order in which teams had pressed their buzzer . Check the code.
Knock yourself out playing.Go wireless;)