{ Fab Academy 2015 : Koichi Shiraishi }
{ Home } { Final project } { Class } { Fab Academy }
- Week 07: Embedded Programming -
Weekly Assignment
- read a microcontroller data sheet
- program your board to do something, with as many different programming languages
- and programming environments as possible
0: Read a data sheet
As start of this week, I check a data sheet of Atmel processor.
1: Installing hardware support
I installed ATtiny support file according to “High-low tech” site.
I am using Arduino IDE 1.6.1. I downloaded the “For Arduino 1.6: ide-1.6.x.zip”, as I moved the directory to "~/ Document/ Arduino"
It is necessary to change the folder name. "attiny-ide-1.6.x" to "hardware"
After rebooting the software, it apply to change.
2: Setting hardware configuration
I set the hardware configuration.
I clicked tool tab, and choose
-
Board> ATtiny
-
Clock> 20Mhz
-
Processor> ATtiny44
-
Port> Serial ports
I burn boot loader by AVRISP mk2, because my FabISP does not operate smoothly.
I set programmer.
-
Programmer> AVRISP mk2
After setting, I burned boot loader.
3: Coding and writing
I wrote a code by C. I modify the code based on the arduino sample.
After then, I check the code.
I Clicked compile. If it has problem, the app return a error.
As I succeeded compile, I burned the code to the machine.
5: Check behavior
momentary
void setup() {
pinMode(3,INPUT) ;
pinMode(7,OUTPUT) ;
}
void loop() {
if (digitalRead(3) == HIGH) {
digitalWrite(7,LOW) ;
} else {
digitalWrite(7,HIGH) ;
}
}
alternate
int inPin=0;//input number
int outPin=13;//output number
int pinData=1;//swich syokijyoutai
boolean led=false;
void setup() {
Serial.begin(9600);
pinMode (inPin,INPUT);
pinMode (outPin,OUTPUT);
}
void loop() {
Serial.println (pinData);
if (digitalRead(inPin)==HIGH){
pinData*=-1;
}else{
pinData*=0;
}
if (pinData==1){
(led=true);
}
else{
(led=false);
}
if(led==true){
digitalWrite(outPin,LOW);
}else{
digitalWrite(outPin,HIGH);
}
delay(200);
}