Assignment
read a microcontroller data sheet (ATtiny24A/44A).
program your Hello button + led board to do something, with as many different programming languages and programming environments as possible.
1.- Programming in Arduino IDE
a.- Install the Software
We need install:
- Arduino IDE software. You can download here.
- ATtiny Board Files. You can download here.
- FTDI Drivers. You can download here.
Installing ATtiny support in Arduino
Locate your Arduino sketchbook folder File > Preferences menu
Create a new sub-folder called "hardware" in the sketchbook folder.
Copy the attiny folder from inside the attiny-master.zip to the hardware folder.
Start the Arduino development environment.
You should see ATtiny entries in the Tools > Board menu.
b.- Power and connect the boards
We need to provide power to the ATtiny, the FabISP(programmer) and connect them with each other.
Connect the 6-pin programming header in the FabISP and the LED-Button board with a cable
Connect the FabISP to the computer with an USB cable
Connect the LED + Button board to the computer with an FTDI cable.
c.- Burn the Bootloader
To burn the Bootloader go to Tools > Burn Bootloader menu.
This configures the fuse bits of the microcontroller so it runs at 8 MHz.
If you are sucessful, you will see this message.
d.- Modify the "Button" example
After open the Button sketch from the examples menu File > Examples > Digital > Button. I have change the pin numbers from the LED and the button because the pinouts on the ATtiny 44A microcontroller are not the same numbers that in the Arduino code.
Arduino pin numbers
buttonPin = 2
ledPin = 13
ATtiny 44A pin numbers
buttonPin = 3
ledPin = 7
I verified the code before I upload the sketch.
To upload the button sketch to the board, click the arrow button.
The led is glowing on the board and when I press the button the led turn off
Now I modified the code to detect when the button changes from off to on and on to off.
I count the number of button presses and I see if the number is odd or even.
If it is odd the led blinks, if it is even the led fade in and fade out.
Arduino code:
const int buttonPin = 3;
const int ledPin = 7;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
int brightness = 0;
int fadeAmount = 5;
I used the serial monitor, in the Arduino IDE, to verify that the board was working.
The program stores the character you type and then echo to the serial monitor.
The program will store each character and repeat the series back to you each time.
When you get the maximum number of characters, the program overwrite the first values.