Hi every one,
as someone said best to start a new thread how as to use a TTiny85 to make a timer that goes logic high or low every 15 mins.
I got my Arduino, but I am still waiting for the ttiny85 chip to come in. but I am going to play around with the Arduino while I'm waiting for my chip to come in.
So if anyone wants to follow and play along with me as I learn this! you must start here first:
this is copied from the user panic mode:
I got my Arduino, but I am still waiting for the ttiny85 chip to come in. but I am going to play around with the Arduino while I'm waiting for my chip to come in.
So if anyone wants to follow and play along with me as I learn this! you must start here first:
this is copied from the user panic mode:
as stated before... do NOT bother with ATTINY... for now.... just use Arduino as is...
1. connect it to your computer using USB cable. power LED on Arduino should light up.
2. start Arduino software
3. start with Blink example (File>Examples>01.Basics>Blink). This will flash another LED that is already on the board.
4. Make sure correct board is selected. if not click on pull down menu to make selection
View attachment 328401
to filter results and shorten the list type something ... like "uno"
at the moment i the only Arduino Uno i have at hand is the R4 Minima (which has different chip) but you will select your board version and click Ok:
View attachment 328402
5. click on transfer and wait couple of seconds.
View attachment 328404
6. Congratulation, you just programmed first microcontroller... now lets start playing...
7. change value in line 34 (first delay instruction) to something smaller... such as 300... then send program again. you should see that blinks are shorter.
8. increase value and send the program again...
9. well that is blinking LED on board... but how about some external LED? no problem, you can check documentation and see that on board LED is on pin 13 - at least on Arduino Uno (this is why the example used variable name instead of hardcoded number. this value is changes according to board you selected in step 4). so connect another LED with resistor to pin 13 and GND. resistor can be 220-470 Ohm. if you do this right, the external LED will flash since it is connected to same pin (pin 13)
10. lets try to use different pin, such as pin 10. go to program and replace all instances of LED_BUILTIN by value 10. there are three places to change it lines 28, 33, and 35).. and of course send the program to Arduino and connect your external LED and resistor from pin 10 to GND.
11. but changing things in three places is annoying... and this was just three places. imagine if the LED_BUILTIN was used in 50 or more places.... that would be nightmare to maintain and modify. it is much more practical to define own name for the pin and use it in program. then if you need to move to another pin, you just change it in one place - in the definition. all other 50 places can stay as is.
12. what if you want more than one LED? add declarations and initialization for each, then use them any way you like... perhaps
then look at other examples (input, analog etc.)Code:const int LED_RED = 10; // this LED is on pin 10 const int LED_GREEN = 11; // this LED is on pin 11 const int LED_BLUE = 12; // this LED is on pin 12 // the setup function runs once when you press reset or power the board void setup() { // specify how pins are used (input or output...) // for driving LEDs they need to be an output pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_RED, OUTPUT); pinMode(LED_GREEN, OUTPUT); pinMode(LED_BLUE, OUTPUT); } // the loop function runs over and over again forever void loop() { // turn all LEDs off digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_RED, LOW); digitalWrite(LED_GREEN, LOW); digitalWrite(LED_BLUE, LOW); delay(200); // wait a bit // then turn them on one by one digitalWrite(LED_RED, HIGH); delay(1000); digitalWrite(LED_GREEN, HIGH); delay(1000); digitalWrite(LED_BLUE, HIGH); delay(1000); digitalWrite(LED_BUILTIN, HIGH); delay(1000); // and turn them off ... in reverse digitalWrite(LED_BUILTIN, LOW); delay(1000); digitalWrite(LED_BLUE, LOW); delay(1000); digitalWrite(LED_GREEN, LOW); delay(1000); digitalWrite(LED_RED, LOW); delay(1000); }


