Created
February 15, 2020 18:54
-
-
Save mattrude/a0a569d234d5dc942c67ff2f5f001299 to your computer and use it in GitHub Desktop.
ATtiny85 Traffic Stop Light - This program turns on (in order) the Red LED, waits for 5 seconds, then turns on the Green LED, waits for 5 seconds, then turns on the Yellow LED, waits for 2.5 seconds and repeats cycle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ATtiny85 Traffic Stop Light - Version 0.1.2 - 2020-02-15 | |
* Copyright (c) 2020 Matt Rude <matt@mattrude.com> | |
* | |
* ********************************************************************************* | |
* | |
* This is a simple Traffic Stop Light program written for an ATtiny85 using | |
* Arduino IDE and the 'attiny' board found at: https://github.com/damellis/attiny | |
* | |
* For more on the ATtiny85, see: https://www.microchip.com/wwwproducts/en/ATtiny85 | |
* | |
* The program turns on (in order) the Red LED, waits for 5 seconds, then turns on | |
* the Green LED, waits for 5 seconds, then turns on the Yellow LED, waits for 2.5 | |
* seconds and repeats cycle. | |
* | |
* The ATtiny85 was programed with the external programer, and is running is at a | |
* clock speed of 1MHz (internal). | |
* | |
* The circuit is powered by an external DC buck converter running at 3.3v. | |
* | |
* ********************************************************************************* | |
* | |
* Required Hardware: | |
* | |
* - 1x 1330 ATtiny85-20pu | |
* - 1x Red LED | |
* - 1x Yellow LED | |
* - 1x Green LED | |
* - 1x 220ohm Resistor | |
* - 1x Breadboard | |
* - 8x Jumper Wires | |
* | |
* Simplified ATtiny85 Pinout: | |
* (Note: the dot next to the Reset pin, represents the dot on the chip.) | |
* ______ | |
* Reset - |. | - 5v+ | |
* A3 - 3 - | | - 2 - A1 | |
* A2 - 4 - | | - 1 - PWM | |
* GND - |______| - 0 - PWM | |
* | |
* | |
* ********************************************************************************* | |
* | |
* Changelog: | |
* | |
* 2020-02-15 - 0.1.2 - Change program to boot with the Red light first. | |
* - Change Red & Green delay to 5 seconds, and Yellow to 2.5. | |
* 2020-02-02 - 0.1.1 - Correct minor spelling and white space cleanup. | |
* 2020-01-30 - 0.1.0 - Initial Release. | |
* | |
* | |
* ********************************************************************************* | |
* | |
* MIT License | |
* | |
* Copyright (c) 2020 Matt Rude <matt@mattrude.com> | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be included in all | |
* copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
* SOFTWARE. | |
* | |
* ********************************************************************************* | |
*/ | |
// Set pin assignments for the ATtiny85 chip. | |
int redLed = 0; | |
int yellowLed = 1; | |
int greenLed = 2; | |
// The Setup Routine | |
void setup() { | |
// Initialize the digital pins as Outputs. | |
pinMode(greenLed, OUTPUT); | |
pinMode(yellowLed, OUTPUT); | |
pinMode(redLed, OUTPUT); | |
} | |
// The Loop Routine. | |
void loop() { | |
digitalWrite(redLed, HIGH); // Turn the Red LED on. | |
delay(5000); // Wait for 5 seconds. | |
digitalWrite(redLed, LOW); // Turn the Red LED off. | |
digitalWrite(greenLed, HIGH); // Turn the Green LED on. | |
delay(5000); // Wait for 5 seconds. | |
digitalWrite(greenLed, LOW); // Turn the Green LED off. | |
digitalWrite(yellowLed, HIGH); // Turn the Yellow LED on. | |
delay(2500); // Wait for 2.5 seconds. | |
digitalWrite(yellowLed, LOW); // Turn the Yellow LED off. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment