changeset 19:012b36935057 tiny10

Use PB1 and PB2 pins
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Wed, 04 Jan 2017 12:09:12 +0100
parents 1d1ca74ade50
children
files main/main.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/main/main.c	Fri Dec 30 23:43:46 2016 +0100
+++ b/main/main.c	Wed Jan 04 12:09:12 2017 +0100
@@ -42,10 +42,10 @@
     while (length --> 0) {
         note.raw = pgm_read_byte_near(notes++);
         if (note.note.octave) {
-            TCCR0B = 1<<WGM02 | 0b001; // /1 prescaler
-            TCNT0L = 0;
+            TCNT0 = 0;
             count = pgm_read_byte_near(FREQ + note.note.tone);
             OCR0A = (count << 3) >> (note.note.octave - 1);
+            TCCR0B = 1<<WGM02 | 0b001; // /1 prescaler
         }
         if (note.note.length) {
             _delay_ms(220);
@@ -56,13 +56,13 @@
             TCCR0B = 0;
             _delay_ms(15);
         }
-        PORTB ^= 1<<1;
+        PORTB ^= 1<<PB2;
     }
 }
 
 int main() {
-    DDRB = 1<<0 | 1<<1;
-    TCCR0A = 1<<COM0A0;
+    DDRB = 1<<PB1 | 1<<PB2;
+    TCCR0A = 1<<COM0B0;
     play(INTRO_NOTES, 26);
     while(1) {
         play(MELODY_NOTES, 216);