MAS.863:How To Make ( almost ) Anything

Embedded Programming

For this week I decided to work on AVR programmers and IDEs. First I implemented helloworld routine using AVRdude program. The program takes C files and generate the hex files necessary and upload them on the board. I used term.py to communicate with the programmed board. One of the errors that I encountered early was the version of python, which needs to be 2.7 for term.py routine.

For the second part I decided to write and program the board using the Arduino IDE. After installing the necessary library for the usbTiny, I wrote the following program for having a LED with 2 different frequency of flashing, that depends on the button press.


const int ledpin = 7;
const int Button = 3;
int buttonMode = 0;
// the setup function runs once when you press reset or power the board

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(ledpin, OUTPUT);
  pinMode(Button, INPUT);
}

// the loop function runs over and over again forever
void loop() {
  buttonMode=digitalRead(Button);
  if (buttonMode==HIGH){
  digitalWrite(ledpin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                       // wait for a second
  digitalWrite(ledpin, LOW);    // turn the LED off by making the voltage LOW
  delay(500);       
  }
  else{
    digitalWrite(ledpin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(ledpin, LOW);    // turn the LED off by making the voltage LOW
  delay(100);   
    }
}

Once the code compiled uploading and testing was straightforward in this environment. The usbTiny green LED blinks when the uploading in progress.

d