#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <math.h>
// Nokia 5110 connections
// CLK, DIN, DC, CE, RST
Adafruit_PCD8544 display =
Adafruit_PCD8544(13, 11, 9, 10, 12);
#define W 84
#define H 48
float angle = 0;
void setup() {
display.begin();
display.setContrast(55);
display.clearDisplay();
display.display();
}
void showTitle(const char *name) {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0, 0);
display.println("AI CENTRE");
display.drawLine(0, 10, 83, 10, BLACK);
display.setCursor(0, 15);
display.println(name);
display.display();
delay(900);
}
void spiral() {
showTitle("SPIRAL ART");
for (int t = 0; t < 500; t++) {
float a = t * 0.12;
int r = t * 0.055;
int x = 42 + r * cos(a);
int y = 24 + r * sin(a);
if (x >= 0 && x < W && y >= 0 && y < H)
display.drawPixel(x, y, BLACK);
if (t % 5 == 0) display.display();
}
}
void circles() {
showTitle("CIRCLE ART");
for (int r = 2; r < 45; r += 3) {
display.drawCircle(42, 24, r, BLACK);
display.display();
delay(70);
}
}
void flower() {
showTitle("FLOWER ART");
for (int a = 0; a < 360; a += 5) {
float t = a * PI / 180;
int x = 42 + 16 * cos(t) * cos(6 * t);
int y = 24 + 13 * sin(t) * cos(6 * t);
display.fillCircle(x, y, 2, BLACK);
display.display();
}
}
void star() {
showTitle("STAR FIELD");
for (int i = 0; i < 100; i++) {
int x = random(W);
int y = random(H);
display.drawPixel(x, y, BLACK);
if (i % 5 == 0) display.display();
delay(20);
}
}
void wave() {
showTitle("WAVE ART");
for (int f = 0; f < 80; f++) {
display.clearDisplay();
for (int x = 0; x < W; x++) {
int y = 24 + 10 * sin((x + f) * 0.13);
display.drawPixel(x, y, BLACK);
display.drawPixel(x, y + 1, BLACK);
}
display.display();
delay(45);
}
}
void mandala() {
showTitle("MANDALA");
for (int r = 4; r < 23; r += 4) {
for (int a = 0; a < 360; a += 15) {
float t = a * PI / 180;
int x = 42 + r * cos(t);
int y = 24 + r * sin(t);
display.drawCircle(x, y, 3, BLACK);
}
display.display();
}
}
void bouncingBall() {
showTitle("BOUNCING BALL");
for (int i = 0; i < 120; i++) {
display.clearDisplay();
int x = 5 + i % 74;
int y = 24 + 17 * sin(i * 0.15);
display.fillCircle(x, y, 4, BLACK);
display.display();
delay(35);
}
}
void diamonds() {
showTitle("DIAMOND ART");
for (int r = 2; r < 24; r += 2) {
display.drawLine(42, 24-r, 42+r, 24, BLACK);
display.drawLine(42+r, 24, 42, 24+r, BLACK);
display.drawLine(42, 24+r, 42-r, 24, BLACK);
display.drawLine(42-r, 24, 42, 24-r, BLACK);
display.display();
}
}
void checker() {
showTitle("CHECKER ART");
for (int y = 12; y < H; y += 6) {
for (int x = 0; x < W; x += 6) {
if ((x / 6 + y / 6) % 2 == 0)
display.fillRect(x, y, 3, 3, BLACK);
}
}
display.display();
delay(1200);
}
void polygon() {
showTitle("POLYGON ART");
for (int n = 3; n <= 12; n++) {
display.clearDisplay();
for (int i = 0; i < n; i++) {
float a1 = 2 * PI * i / n;
float a2 = 2 * PI * (i + 1) / n;
display.drawLine(
42 + 20 * cos(a1), 24 + 20 * sin(a1),
42 + 20 * cos(a2), 24 + 20 * sin(a2),
BLACK);
}
display.display();
delay(250);
}
}
void lightning() {
showTitle("LIGHTNING");
for (int i = 0; i < 15; i++) {
display.clearDisplay();
int x = random(10, 75);
int y = 0;
for (int j = 0; j < 7; j++) {
int nx = x + random(-8, 9);
int ny = y + 7;
display.drawLine(x, y, nx, ny, BLACK);
x = nx;
y = ny;
}
display.display();
delay(150);
}
}
void spiralCircles() {
showTitle("ORBIT ART");
for (int f = 0; f < 80; f++) {
display.clearDisplay();
for (int i = 0; i < 5; i++) {
float a = (f + i * 16) * 0.1;
int x = 42 + 18 * cos(a);
int y = 24 + 12 * sin(a);
display.drawCircle(x, y, 4, BLACK);
}
display.display();
delay(60);
}
}
void sinePattern() {
showTitle("SINE PATTERN");
for (int f = 0; f < 100; f++) {
display.clearDisplay();
for (int x = 0; x < W; x++) {
for (int k = 0; k < 3; k++) {
int y = 24 + 7 * sin(x * 0.12 + f * 0.1 + k * 2);
display.drawPixel(x, y, BLACK);
}
}
display.display();
delay(50);
}
}
void tunnel() {
showTitle("3D TUNNEL");
for (int f = 0; f < 70; f++) {
display.clearDisplay();
for (int r = 2; r < 30; r += 4) {
display.drawRect(
42-r, 24-r/2, r*2, r, BLACK);
}
display.display();
delay(60);
}
}
void rain() {
showTitle("RAIN EFFECT");
int x[20], y[20];
for (int i = 0; i < 20; i++) {
x[i] = random(W);
y[i] = random(H);
}
for (int f = 0; f < 100; f++) {
display.clearDisplay();
for (int i = 0; i < 20; i++) {
display.drawLine(x[i], y[i], x[i]-1, y[i]+4, BLACK);
y[i] += 3;
if (y[i] > H) {
y[i] = 0;
x[i] = random(W);
}
}
display.display();
delay(45);
}
}
void finalScreen() {
display.clearDisplay();
display.drawRect(0, 0, 84, 48, BLACK);
display.drawRect(3, 3, 78, 42, BLACK);
display.setTextSize(1);
display.setCursor(8, 9);
display.println("16 ART DONE");
display.setCursor(5, 23);
display.println("ARVIND PATIL");
display.setCursor(8, 35);
display.println("AI CENTRE");
display.display();
delay(3000);
}
void loop() {
spiral(); // 1
circles(); // 2
flower(); // 3
star(); // 4
wave(); // 5
mandala(); // 6
bouncingBall(); // 7
diamonds(); // 8
checker(); // 9
polygon(); // 10
lightning(); // 11
spiralCircles(); // 12
sinePattern(); // 13
tunnel(); // 14
rain(); // 15
// 16 - Signature art
finalScreen();
}
Loading
nokia-5110
nokia-5110
https://wokwi.com/projects/466170235301409793
for code and details