Programming for Microcontroller

This week I wrote codes and burned the codes into my helloecho board from week 5.

-------------

Hardware

1. 6 pin cable

2. FTDI cable

3. FabISP programmer

4. HelloEcho Board

5. 2 usb to mini usb cables

CONNECT

Software

1. Driver for FabISP

2. Driver for FTDI cable

my PC(win8 OS) just install it automaticcally

3. Arduino IDE

I followed this tutorial to set up arduino IDE. This step upload ATTiny board to arduino IDE

-------------

-------------

-------------

Programming and Debugging

CONNECT

The pin number for ATtiny chip.

Tree Rack

My HelloEcho Board

Tree Rack

To first try if my board works or not, I just write a simple code, and upload my code using

FabISP. After I press the upload button in Arduino IDE, IDE indicates it is successful.

But LED which is L1 in board image does not light up. Then I check the connection between LED pin

and GND. The wire is ok, but why does my LED not blink. And I check the polarity of LED. The annode is

is connected to PIN 7.

-------------

-------------

I believe my ATTiny chip is soldered correctly to the board, otherwise I won't be able to upload my codes

To check, I burn Neil's hello echo example C and Make file code.

In windows, the command in GitBash is a little different from Linux, so I just type the code below

							
							make -f hello.ftdi.44.echo.c.make
							make -f hello.ftdi.44.echo.c.make program-usbtiny-fuses
							make -f hello.ftdi.44.echo.c.make program-usbtiny
							
						

I open the serial monitor in arduino IDE with a 115200 baudrate to see if the board echos

Tree Rack

The echo code works.

-------------

-------------

So I just try switch the polarity of the LED, and upload the code again, and magically it works.

								
								const int ledPin = 7;
								const int buttonPin = 3;

								int blinkSpeed;
								const int blinkFast = 10;
								const int blinkSlow = 50;

								void setup() {
								  pinMode(ledPin, OUTPUT);
								  pinMode(buttonPin, INPUT_PULLUP);
								}

								void loop() {
								  if(digitalRead(buttonPin) == LOW)
								  {
									blinkSpeed = blinkSlow;
								  } 
								  else {
									blinkSpeed = blinkFast;
								  }

								  digitalWrite(ledPin, HIGH);
								  delay(blinkSpeed);
								  digitalWrite(ledPin, LOW);
								  delay(blinkSpeed);
								}
								
							

-------------

-------------

-------------