Skip to content

Commit 42e06a3

Browse files
authored
Add files via upload
1 parent f62cbfa commit 42e06a3

File tree

2 files changed

+289
-0
lines changed

2 files changed

+289
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#include <SPI.h>
2+
#include <Wire.h>
3+
#include <Adafruit_GFX.h>
4+
#include <Adafruit_SSD1306.h>
5+
6+
#define SCREEN_WIDTH 128 // OLED display width, in pixels
7+
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
8+
9+
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
10+
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
11+
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
12+
13+
#define NUMFLAKES 10 // Number of snowflakes in the animation example
14+
15+
#define LOGO_HEIGHT 64
16+
#define LOGO_WIDTH 128
17+
18+
// 'CD_new_Logo', 128x64px
19+
static const unsigned char PROGMEM logo [] PROGMEM = {
20+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35+
0xff, 0xcf, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
36+
0xff, 0xce, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
37+
0xff, 0xce, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
38+
0xff, 0xc6, 0x38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0, 0x27, 0xff, 0xff, 0x0e, 0x1c, 0x71, 0xe1, 0xe1, 0xc3, 0xc7, 0x8f, 0x1f, 0x8f,
50+
0xf3, 0x39, 0xf8, 0x27, 0xff, 0xff, 0x00, 0x3c, 0x71, 0xf0, 0xf0, 0x07, 0xc0, 0x0f, 0x1f, 0x8f,
51+
0x03, 0x19, 0x8c, 0x20, 0x7f, 0xff, 0xc0, 0x7c, 0x71, 0xf8, 0xf8, 0x0f, 0xe0, 0x1f, 0x1f, 0x8f,
52+
0x03, 0x19, 0x84, 0x20, 0x7f, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xf8, 0x7f, 0xff, 0xff,
53+
0x03, 0x1d, 0x86, 0x20, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
54+
0xf3, 0x0d, 0x86, 0x27, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xdf, 0xff, 0xff, 0xff, 0xff,
55+
0xf3, 0x01, 0x84, 0x27, 0xff, 0xfe, 0x03, 0xef, 0x80, 0xe0, 0x1e, 0x03, 0x00, 0x7f, 0xff, 0xff,
56+
0xf3, 0x01, 0x8c, 0x23, 0xff, 0xfe, 0xf9, 0xef, 0x3e, 0x67, 0xfc, 0xf3, 0xf7, 0xff, 0xff, 0xff,
57+
0x03, 0x01, 0xfc, 0x20, 0x7f, 0xfe, 0xfc, 0xee, 0x7e, 0x67, 0xfc, 0xfb, 0xf7, 0xff, 0xff, 0xff,
58+
0x03, 0x01, 0xf0, 0x20, 0x7f, 0xfe, 0xfe, 0xee, 0xff, 0xe7, 0xfc, 0xff, 0xf7, 0xff, 0xff, 0xff,
59+
0xf1, 0x00, 0x00, 0x63, 0xff, 0xfe, 0xfe, 0xee, 0xff, 0xe0, 0x1e, 0x0f, 0xf7, 0xff, 0xff, 0xff,
60+
0xf9, 0x80, 0x00, 0x67, 0xff, 0xfe, 0xfe, 0xee, 0xf0, 0x60, 0x1f, 0x83, 0xf7, 0xff, 0xff, 0xff,
61+
0xf9, 0xc0, 0x01, 0xc7, 0xff, 0xfe, 0xfe, 0xee, 0xf8, 0x67, 0xff, 0xf1, 0xf7, 0xff, 0xff, 0xff,
62+
0xf8, 0x7f, 0xff, 0x8f, 0xff, 0xfe, 0xfc, 0xee, 0x7f, 0x67, 0xfd, 0xf9, 0xf7, 0xff, 0xff, 0xff,
63+
0xfc, 0x00, 0x00, 0x1f, 0xff, 0xfe, 0xfc, 0xee, 0x7e, 0x67, 0xfc, 0xf9, 0xf7, 0xff, 0xff, 0xff,
64+
0xff, 0x00, 0x00, 0x3f, 0xff, 0xfe, 0x71, 0xef, 0x1c, 0x67, 0xfc, 0x73, 0xf7, 0xff, 0xff, 0xff,
65+
0xff, 0xc6, 0x38, 0xff, 0xff, 0xfe, 0x03, 0xef, 0x81, 0xe0, 0x0f, 0x07, 0xf7, 0xff, 0xff, 0xff,
66+
0xff, 0xc6, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
67+
0xff, 0xce, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
68+
0xff, 0xce, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
69+
0xff, 0xcf, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
70+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
82+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
84+
};
85+
86+
void setup() {
87+
Serial.begin(115200);
88+
89+
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
90+
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
91+
Serial.println(F("SSD1306 allocation failed"));
92+
for (;;); // Don't proceed, loop forever
93+
}
94+
95+
96+
97+
// Clear the buffer
98+
display.clearDisplay();
99+
100+
display.drawBitmap(0, 0, logo, LOGO_WIDTH,LOGO_HEIGHT,WHITE);
101+
display.display();
102+
103+
}
104+
105+
void loop() {
106+
delay(1);
107+
}
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#include <Wire.h>
2+
#include <Adafruit_GFX.h>
3+
#include <Adafruit_SSD1306.h>
4+
#define SCREEN_WIDTH 128 // OLED display width, in pixels
5+
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
6+
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
7+
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
8+
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
9+
void setup()
10+
{
11+
Serial.begin(115200);
12+
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
13+
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
14+
Serial.println(F("SSD1306 allocation failed"));
15+
for (;;); // Don't proceed, loop forever
16+
}
17+
// Clear the buffer.
18+
display.clearDisplay();
19+
20+
// Display Text
21+
display.setTextSize(1);
22+
display.setTextColor(WHITE);
23+
display.setCursor(0, 28);
24+
display.println("Hello world!");
25+
display.display();
26+
delay(2000);
27+
display.clearDisplay();
28+
29+
// Display Inverted Text
30+
display.setTextColor(BLACK, WHITE); // 'inverted' text
31+
display.setCursor(0, 28);
32+
display.println("Hello world!");
33+
display.display();
34+
delay(2000);
35+
display.clearDisplay();
36+
37+
// Changing Font Size
38+
display.setTextColor(WHITE);
39+
display.setCursor(0, 24);
40+
display.setTextSize(2);
41+
display.println("Hello!");
42+
display.display();
43+
delay(2000);
44+
display.clearDisplay();
45+
46+
// Display Numbers
47+
display.setTextSize(1);
48+
display.setCursor(0, 28);
49+
display.println(123456789);
50+
display.display();
51+
delay(2000);
52+
display.clearDisplay();
53+
54+
// Specifying Base For Numbers
55+
display.setCursor(0, 28);
56+
display.print("0x"); display.print(0xFF, HEX);
57+
display.print("(HEX) = ");
58+
display.print(0xFF, DEC);
59+
display.println("(DEC)");
60+
display.display();
61+
delay(2000);
62+
display.clearDisplay();
63+
64+
// Display ASCII Characters
65+
display.setCursor(0, 24);
66+
display.setTextSize(2);
67+
display.write(1);
68+
display.display();
69+
delay(2000);
70+
display.clearDisplay();
71+
72+
// Scroll full screen
73+
display.setCursor(0, 0);
74+
display.setTextSize(1);
75+
display.println("Full");
76+
display.println("screen");
77+
display.println("scrolling!");
78+
display.display();
79+
display.startscrollright(0x00, 0x07);
80+
delay(4500);
81+
display.stopscroll();
82+
delay(1000);
83+
display.startscrollleft(0x00, 0x07);
84+
delay(4500);
85+
display.stopscroll();
86+
delay(1000);
87+
display.startscrolldiagright(0x00, 0x07);
88+
delay(4500);
89+
display.startscrolldiagleft(0x00, 0x07);
90+
delay(4500);
91+
display.stopscroll();
92+
display.clearDisplay();
93+
94+
//draw rectangle
95+
display.setTextSize(1);
96+
display.setTextColor(WHITE);
97+
display.setCursor(0, 0);
98+
display.println("Rectangle");
99+
display.drawRect(0, 15, 60, 40, WHITE);
100+
display.display();
101+
delay(2000);
102+
display.clearDisplay();
103+
104+
//draw filled rectangle
105+
display.setTextSize(1);
106+
display.setTextColor(WHITE);
107+
display.setCursor(0, 0);
108+
display.println("Filled Rectangle");
109+
display.fillRect(0, 15, 60, 40, WHITE);
110+
display.display();
111+
delay(2000);
112+
display.clearDisplay();
113+
114+
//draw rectangle with rounded corners
115+
display.setTextSize(1);
116+
display.setTextColor(WHITE);
117+
display.setCursor(0, 0);
118+
display.println("Round Rectangle");
119+
display.drawRoundRect(0, 15, 60, 40, 8, WHITE);
120+
display.display();
121+
delay(2000);
122+
display.clearDisplay();
123+
124+
//draw filled rectangle with rounded corners
125+
display.setTextSize(1);
126+
display.setTextColor(WHITE);
127+
display.setCursor(0, 0);
128+
display.println("Filled Round Rectangl");
129+
display.fillRoundRect(0, 15, 60, 40, 8, WHITE);
130+
display.display();
131+
delay(2000);
132+
display.clearDisplay();
133+
134+
//draw circle
135+
display.setTextSize(1);
136+
display.setTextColor(WHITE);
137+
display.setCursor(0, 0);
138+
display.println("Circle");
139+
display.drawCircle(20, 35, 20, WHITE);
140+
display.display();
141+
delay(2000);
142+
display.clearDisplay();
143+
144+
145+
//draw filled circle
146+
display.setTextSize(1);
147+
display.setTextColor(WHITE);
148+
display.setCursor(0, 0);
149+
display.println("Filled Circle");
150+
display.fillCircle(20, 35, 20, WHITE);
151+
display.display();
152+
delay(2000);
153+
display.clearDisplay();
154+
155+
156+
//draw triangle
157+
display.setTextSize(1);
158+
display.setTextColor(WHITE);
159+
display.setCursor(0, 0);
160+
display.println("Triangle");
161+
display.drawTriangle(30, 15, 0, 60, 60, 60, WHITE);
162+
display.display();
163+
delay(2000);
164+
display.clearDisplay();
165+
166+
167+
//draw filled triangle
168+
display.setTextSize(1);
169+
display.setTextColor(WHITE);
170+
display.setCursor(0, 0);
171+
display.println("Filled Triangle");
172+
display.fillTriangle(30, 15, 0, 60, 60, 60, WHITE);
173+
display.display();
174+
delay(2000);
175+
display.clearDisplay();
176+
177+
178+
179+
180+
}
181+
182+
void loop() {}

0 commit comments

Comments
 (0)