Excellent instructions on how to program using the Arduino IDE:
https://digistump.com/wiki/digispark/tutorials/connecting
Only advice I would add is that I found it best to stop a program run by pulling out the USB cable and let ATtiny85 go dead for a few minutes while writing the next one - then plug in after starting the new program on the PC. The instructions suggest briefly pull it out and plug it in again when we run a new program but that gave errors which went away when I did the longer disconnect.
I am interested in using ATtiny85 to run hobby servos.
I run my first code "sketch" (see below) - and it gives me 2 pieces of good news:
- the "delayMicroseconds()" method works on an ATtiny85
- although "delayMicroseconds()" specifies "unsigned int" as the data type, I found it was working OK with common ordinary "int".
int m = 16000; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(0, OUTPUT); //LED on Model B pinMode(1, OUTPUT); //LED on Model A or Pro } // the loop routine runs over and over again forever: void loop() { digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(1, HIGH); //delay(200); delayMicroseconds(m); delayMicroseconds(m); delayMicroseconds(m); delayMicroseconds(m); delayMicroseconds(m); delayMicroseconds(m); digitalWrite(0, LOW); // turn the LED off by making the voltage LOW digitalWrite(1, LOW); delay(3000); // wait for 3 seconds }
No comments:
Post a Comment