Skip to content

Commit c009021

Browse files
committed
tiny support
1 parent 8e00506 commit c009021

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+9319
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
OptoProbe
3+
Checks the input line for changes and lights one of two lights if the input changes.
4+
*/
5+
6+
// Predefined pin numbers
7+
int ledHi = 4;
8+
int ledLo = 3;
9+
int optoIn = 2;
10+
11+
int lastRead; // keep the last pin number
12+
13+
// Set up the LEDs as outputs and pull up the input line (useful when there is no opto card)
14+
void setup() {
15+
// initialize the digital pin as an output.
16+
pinMode(ledHi, OUTPUT);
17+
pinMode(ledLo, OUTPUT);
18+
pinMode(optoIn, INPUT_PULLUP);
19+
lastRead = digitalRead(optoIn); // prime the last read of the opto in
20+
}
21+
22+
// loop repeatedly reads the opto line and compares it to the previous read
23+
// if the line changed and went low, light the LOW LED for 250 mS
24+
// if the line changed and went high, light the HIGH LED for 250 mS
25+
26+
void loop()
27+
{
28+
int readVal;
29+
readVal = digitalRead(optoIn); // read the input line
30+
if (readVal != lastRead) // check if the line changed
31+
{
32+
if (readVal == 1) // if the line went from low to high
33+
digitalWrite(ledHi, HIGH); // turn the LED on (HIGH is the voltage level)
34+
else
35+
digitalWrite(ledLo, HIGH); // if the line went from high to low
36+
delay(250); // wait for a second
37+
lastRead = readVal;
38+
}
39+
digitalWrite(ledHi, LOW); // turn the LED off by making the voltage LOW
40+
digitalWrite(ledLo, LOW); // turn the LED off by making the voltage LOW
41+
delay(100); // wait for a 1/10 second
42+
}
43+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
OptoProbe
3+
Checks the input line for changes and lights one of two lights if the input changes.
4+
*/
5+
6+
// Predefined pin numbers
7+
int ledHi = 2;
8+
int ledPulse = 4;
9+
int optoIn = 3;
10+
11+
int lastRead; // keep the last pin number
12+
13+
// Set up the LEDs as outputs and pull up the input line (useful when there is no opto card)
14+
void setup() {
15+
// initialize the digital pin as an output.
16+
pinMode(ledHi, OUTPUT);
17+
pinMode(ledPulse, OUTPUT);
18+
pinMode(optoIn, INPUT_PULLUP);
19+
lastRead = digitalRead(optoIn); // prime the last read of the opto in
20+
}
21+
22+
// loop repeatedly reads the opto line and compares it to the previous read
23+
// if the line changed and went low, light the LOW LED for 250 mS
24+
// if the line changed and went high, light the HIGH LED for 250 mS
25+
26+
void loop()
27+
{
28+
int readVal;
29+
readVal = digitalRead(optoIn); // read the input line
30+
if (readVal != lastRead) // check if the line changed
31+
{
32+
digitalWrite(ledHi,readVal);
33+
digitalWrite(ledPulse, HIGH); // turn the LED on (HIGH is the voltage level)
34+
delay(250); // wait for a second
35+
digitalWrite(ledPulse, LOW); // if the line went from high to low
36+
lastRead = readVal;
37+
}
38+
// digitalWrite(ledHi, LOW); // turn the LED off by making the voltage LOW
39+
// digitalWrite(ledLo, LOW); // turn the LED off by making the voltage LOW
40+
delay(100); // wait for a 1/10 second
41+
}
42+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Sample Sketch for TinyGrid85
2+
// Bounces LED from one pin to another
3+
4+
// LED pins on 0-4
5+
int LED0 = 0;
6+
int LED1 = 1;
7+
int LED2 = 2;
8+
int LED3 = 3;
9+
int LED4 = 4;
10+
11+
int ledNum; // the current LED that is lighted
12+
13+
void setup()
14+
{
15+
ledNum = 0; // start with D0 LED
16+
pinMode(LED0, OUTPUT);
17+
pinMode(LED1, OUTPUT);
18+
pinMode(LED2, OUTPUT);
19+
pinMode(LED3, OUTPUT);
20+
pinMode(LED4, OUTPUT);
21+
}
22+
23+
void loop()
24+
{
25+
// a very simple switch statement
26+
switch (ledNum)
27+
{
28+
case 0x0:
29+
digitalWrite(LED0, HIGH);
30+
delay(250);
31+
digitalWrite(LED0, LOW);
32+
ledNum = 1;
33+
case 0x1:
34+
digitalWrite(LED1, HIGH);
35+
delay(250);
36+
digitalWrite(LED1, LOW);
37+
ledNum = 2;
38+
case 0x2:
39+
digitalWrite(LED2, HIGH);
40+
delay(250);
41+
digitalWrite(LED2, LOW);
42+
ledNum = 3;
43+
case 0x3:
44+
digitalWrite(LED3, HIGH);
45+
delay(250);
46+
digitalWrite(LED3, LOW);
47+
ledNum = 4;
48+
case 0x4:
49+
digitalWrite(LED4, HIGH);
50+
delay(250);
51+
digitalWrite(LED4, LOW);
52+
ledNum = 0;
53+
}
54+
delay(250);
55+
}
56+

0 commit comments

Comments
 (0)