I am doing a prototype using ATmega8LATmega8L-8PU to detect temperature and control a relay and buzz. Butbuzzer, but the schematic seems not work, therefore I do a simple test to verify the AVR's pins are working perfectly or not.
I using the example sketch - Blink to control Digital-13 to let LED blink. It is work. Then
Then I do a second sketch to test all pins (Due to leak of LED, I test first 8 pins.) it is failIt failed.
Second Sketch Second Sketch is quite simple and strickstrict forward. Blink: blink D0-D7 LED one by one.
char i, j, pcnt = 1;
char startDigitalPin = 0;
char maxDigitalPin = 7;
void setup()
{
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
// put your setup code here, to run once:
for(i=startDigitalPin; i<=maxDigitalPin; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
}
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
for(i=startDigitalPin; i<=maxDigitalPin; i++) {
for(j=i; j<=maxDigitalPin; j++) {
digitalWrite(j, HIGH);
delay(100 * pcnt);
digitalWrite(j, LOW);
delay(100 * pcnt);
}
digitalWrite(i, HIGH);
delay(200 * pcnt);
}
pcnt++;
if(pcnt > 10) {
pcnt = 1;
delay(8000);
}
}