PWM pins

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
janowatzki
 
Posts: 32
Joined: Thu Jun 04, 2015 9:42 pm

PWM pins

Post by janowatzki »

Awhile back I made the Trinket Analog Meter clock, loved it! Anyway I'm trying to make another one with a Boarduino (328P) that I got laying around. I'm confused about which pins on the Boarduino to use for PWM. I look at the Atmega 328 pinout and compare to the Trinket thinking I can just replace pin numbers in the sketch but it's not as smooth a process as I first thought. Apart from PWM the pins all serve other various functions.

Thank you
Jerry

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: PWM pins

Post by adafruit_support_bill »

PWN capable pins on the Boarduino are the same as for an UNO. Pins 3, 5, 6, 9, 10 & 11.

User avatar
janowatzki
 
Posts: 32
Joined: Thu Jun 04, 2015 9:42 pm

Re: PWM pins

Post by janowatzki »

Thanks for the quick responce, didnt expect that on a weekend! I went throught the original sketch and changet the hours (pin 1) to pin 3 and minute (pin 4) to pin 5. heres the error when I compile:
Arduino: 1.8.5 (Linux), Board: "Arduino Duemilanove or Diecimila, ATmega328P"

/home/jerry/Arduino/Nano_analog_clock/Boarduino_analog_clock.ino/Boarduino_analog_clock.ino.ino: In function 'void PWM5_init()':
Boarduino_analog_clock.ino:80: error: 'TCCR1' was not declared in this scope
TCCR1 = _BV (CS10); // no prescaler
^
In file included from /home/jerry/arduino-1.8.5/hardware/tools/avr/avr/include/avr/io.h:99:0,
from /home/jerry/arduino-1.8.5/hardware/tools/avr/avr/include/avr/pgmspace.h:90,
from /home/jerry/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Arduino.h:28,
from sketch/Boarduino_analog_clock.ino.ino.cpp:1:
Boarduino_analog_clock.ino:81: error: 'PWM1B' was not declared in this scope
GTCCR = _BV (COM1B1) | _BV (PWM1B); // clear OC1B on compare
^
Boarduino_analog_clock.ino:83: error: 'OCR1C' was not declared in this scope
OCR1C = 255; // frequency
^
exit status 1
'TCCR1' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Is this a side effect of not using the Trinket?

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: PWM pins

Post by adafruit_support_bill »

Is this a side effect of not using the Trinket?
Yes. The timers - and associated timer registers on the Atmega-328P are different from the ones on the ATTiny85.

Arduino timers are an advanced topic, but there are a few good tutorials out there:
http://sphinx.mythic-beasts.com/~markt/ ... imers.html
https://arduino-info.wikispaces.com/Timers-Arduino
https://oscarliang.com/arduino-timer-an ... -tutorial/

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”