Skip to content

Commit 4d64de6

Browse files
author
Jim Lindblom
committed
Merge pull request #8 from nseidle/master
Added multimode support - volt meter and counter modes added.
2 parents 79ec0f9 + d759cbc commit 4d64de6

File tree

9 files changed

+655
-507
lines changed

9 files changed

+655
-507
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
11-24-2012
3+
Spark Fun Electronics
4+
Nathan Seidle
5+
6+
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
7+
8+
Serial7Segment is an open source seven segment display.
9+
10+
This is example code puts the display into counter mode.
11+
12+
Note: This code expects the display to be listening at 9600bps. If your display is not at 9600bps, you can
13+
do a software or hardware reset. See the Wiki for more info:
14+
http://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands#wiki-baud
15+
16+
To get this code to work, attached an Serial7Segment to an Arduino Uno using the following pins:
17+
Pin 8 on Uno (software serial TX) to RX on Serial7Segment
18+
VIN to PWR
19+
GND to GND
20+
Button on SDI (Increment)
21+
Button on SDO (Decrement)
22+
23+
*/
24+
25+
#include <SoftwareSerial.h>
26+
27+
SoftwareSerial Serial7Segment(7, 8); //RX pin, TX pin
28+
29+
#define MODE_CMD 0x82
30+
31+
#define MODE_DATA 0
32+
#define MODE_ANALOG 1
33+
#define MODE_COUNTER 2
34+
35+
int cycles = 0;
36+
37+
void setup() {
38+
39+
Serial.begin(9600);
40+
Serial.println("OpenSegment Example Code");
41+
42+
Serial7Segment.begin(9600); //Talk to the Serial7Segment at 9600 bps
43+
Serial7Segment.write('v'); //Reset the display - this forces the cursor to return to the beginning of the display
44+
45+
delay(10);
46+
Serial7Segment.write(MODE_CMD); //Change the mode of the display
47+
// Serial7Segment.write(MODE_COUNTER); //Enter counter mode. Any pulse on SDI will go up. Any pulse on SDO will go down.
48+
// Serial7Segment.write(MODE_ANALOG); //Enter analog mode. Unit will display the analog voltages detected on A6/A7.
49+
Serial7Segment.write((byte)MODE_DATA); //Return to normal mode. You can also do a hardware reset to return to normal data mode.
50+
51+
}
52+
53+
void loop()
54+
{
55+
//Do nothing. User must hit momentary buttons connected to SDI/SDO
56+
}
57+
58+
59+

firmware/Serial 7-Segment Display/Arduino_Examples/S7S_Example_Serial_Basic/S7S_Example_Serial_Basic.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
http://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands#wiki-baud
1515
1616
To get this code to work, attached an Serial7Segment to an Arduino Uno using the following pins:
17-
Pin 7 on Uno (software serial RX) to TX on Serial7Segment
18-
Pin 8 on Uno to RX on Serial7Segment
17+
Pin 8 on Uno (software serial TX) to RX on Serial7Segment
1918
VIN to PWR
2019
GND to GND
2120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
11-21-2012
3+
Spark Fun Electronics
4+
Nathan Seidle
5+
6+
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
7+
8+
Serial7Segment is an open source seven segment display.
9+
10+
This is example code that shows how to control individual segments on each digit. Sort of like
11+
the Predator display at the end of the movie when he blows himself up.
12+
13+
Note: This code expects the display to be listening at 9600bps. If your display is not at 9600bps, you can
14+
do a software or hardware reset. See the Wiki for more info:
15+
http://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands#wiki-baud
16+
17+
To get this code to work, attached an Serial7Segment to an Arduino Uno using the following pins:
18+
Pin 8 on Uno to RX on Serial7Segment
19+
VIN to PWR
20+
GND to GND
21+
22+
*/
23+
24+
//From https://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands#wiki-individual
25+
#define SEGMENT1 0
26+
#define SEGMENT2 1
27+
#define SEGMENT3 2
28+
#define SEGMENT4 3
29+
#define SEGMENT5 4
30+
#define SEGMENT6 5
31+
#define SEGMENT7 6
32+
33+
#define DIGIT1 0x7B
34+
#define DIGIT2 0x7C
35+
#define DIGIT3 0x7D
36+
#define DIGIT4 0x7E
37+
38+
#include <SoftwareSerial.h>
39+
40+
SoftwareSerial Serial7Segment(7, 8); //RX pin, TX pin
41+
42+
void setup() {
43+
44+
Serial.begin(9600);
45+
Serial.println("OpenSegment Example Code");
46+
47+
Serial7Segment.begin(9600); //Talk to the Serial7Segment at 9600 bps
48+
Serial7Segment.write('v'); //Reset the display - this forces the cursor to return to the beginning of the display
49+
50+
//Here's the basic example
51+
Serial7Segment.write(DIGIT1); // Control individual segments on a digit
52+
Serial7Segment.write( (1<<SEGMENT1) | (1<<SEGMENT4) | (1<<SEGMENT7) ); // Turn on certain segments
53+
54+
Serial7Segment.write(DIGIT2); // Control individual segments on a digit
55+
Serial7Segment.write( (1<<SEGMENT2) | (1<<SEGMENT5) | (1<<SEGMENT7) ); // Turn on certain segments
56+
57+
Serial7Segment.write(DIGIT3); // Control individual segments on a digit
58+
Serial7Segment.write( (1<<SEGMENT4) | (1<<SEGMENT5) ); // Turn on certain segments
59+
60+
Serial7Segment.write(DIGIT4); // Control individual segments on a digit
61+
Serial7Segment.write( (1<<SEGMENT5) | (1<<SEGMENT6) | (1<<SEGMENT7) ); // Turn on certain segments
62+
63+
delay(1500);
64+
65+
//Here's the more fun example
66+
67+
//Seed random generator with analog input - nothing needs to be connected to A0
68+
randomSeed(analogRead(0));
69+
}
70+
71+
void loop()
72+
{
73+
for(int x = 0 ; x < 4 ; x++)
74+
{
75+
byte randNumber = random(0, 127); //Give me random number between 0 and 127
76+
Serial7Segment.write(DIGIT1 + x); //Control individual segments on a digit
77+
Serial7Segment.write(randNumber); //Turn on random segments
78+
}
79+
80+
delay(1000);
81+
}
82+
83+
84+

firmware/Serial 7-Segment Display/Arduino_Examples/Test_I2C/Test_I2C.ino

Lines changed: 0 additions & 74 deletions
This file was deleted.

firmware/Serial 7-Segment Display/Arduino_Examples/Test_SPI/Test_SPI.ino

Lines changed: 0 additions & 61 deletions
This file was deleted.

firmware/Serial 7-Segment Display/Arduino_Examples/Test_jig/Test_jig.ino

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)