INPUT

In this assignment I had to:
* read a microcontroller data sheet
* program my board to do something, with as many different programming languages and programming environments as possible.

LESSON >>video recording - web

PROCESS

I used my two board fabricated in my assignment 06 ELECTRONIC DESIGN.

It is very important to remember configuration pins of our microcrontoller.

I used :
pin 13 | PA0 as INPUT (pushbutton)
pin 10 | PA2 as OUTPUT (led 1)
pin 11 | PA3 as OUTPUT (led 2 )

Only to remember my schematic file

Motherboard
Input | Output board
PROGRAMMING WITH ARDUINO >> Install ARDUINO Finally I installed version 1.0.6 because the newest give me some problems with libraries.

Get Attiny microcontroller librarie You can find zip file here.
Unzip and move folder attiny in the folder hardware, I created that folder into the same folder of Arduino C:\Users\Henry\Documents\Arduino. When I opened Arduino, I saw my ATtiny 44 microcontroller in Tools/Board

Prepare USB PORT Get Driver USBTinyISP.and install it. I installed 64 version for windows 8.
Remember to install drivers for FABIsp.
It is time to progran When buttom is presed LEDS are changing between ON and OFF.
Now, when I press the buttomh firts time LEDS will change status
Finally, I considered to avoid rebound buttom.

OUTPUT

Copy and paste the code bellow:

            // setting PIN numbers:
            int IN_BUTTON =  0;      // pushbutton
            int OUT_LED1 = 2;     // led 1
            int OUT_LED2 =  3;    // led 2
            
            // initializing status:
            int buttonSTATUS = 0;   // variable for reading the pushbutton status
            int lastSTATUS = 0;     // saving the last status of the buttom
            int outputSTATUS = 0;   // 0 = LED OFF  1 = LED ON
            
            // setting INPUIS and OUTPUTS
            void setup() {
              pinMode(IN_BUTTON, INPUT);  // initializing PUSH BUTTOM pin as an input:
              pinMode(OUT_LED1, OUTPUT);  // initializing LED 1 pin as an output:
              pinMode(OUT_LED2, OUTPUT);  // initializing LED 2 pin as an output: 
            }
            
            // making the program
            void loop(){   
               buttonSTATUS = digitalRead(IN_BUTTON); // reading and saving the status of the pushbutton:
              
              if ((buttonSTATUS == HIGH) && (lastSTATUS == LOW)){
                outputSTATUS = 1-outputSTATUS;
                delay(20); // to avoid buttom rebound
              }
              
              lastSTATUS = buttonSTATUS; // save the actual value
              // checking if pushbutton is pressed.
              if (outputSTATUS == 1) {    
                // LEDS ON / OFF:   
              digitalWrite(OUT_LED1, HIGH); // LED 1 ON
              digitalWrite(OUT_LED2, LOW);  // LED 2 OFF 
              delay(50);            // wait for 500ms
              digitalWrite(OUT_LED1, LOW);  // LED 1 OFF 
              digitalWrite(OUT_LED2, HIGH); // LED 2 ON
              delay(50);                  
              }
              else {
                // LEDS OFF: 
              digitalWrite(OUT_LED1, LOW);  // LED 1 OFF
              digitalWrite(OUT_LED2, LOW);  // LED 2 OFF 
              }
            }
            






>>> COMMENTS