Skip to content

Instantly share code, notes, and snippets.

@vampjaz
Created September 9, 2015 14:56
Show Gist options
  • Save vampjaz/b3571eee2a70ef76d338 to your computer and use it in GitHub Desktop.
Save vampjaz/b3571eee2a70ef76d338 to your computer and use it in GitHub Desktop.
Coolfractal on a nokia 5110 GLCD
/*********************************************************************
This is an example sketch for our Monochrome Nokia 5110 LCD Displays
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/338
These displays use SPI to communicate, 4 or 5 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#define SIZECON 2.4
#define PIN_SCE 8
#define PIN_RESET 4
#define PIN_DC 5
#define PIN_SDIN 6
#define PIN_SCLK 7
Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK,PIN_SDIN,PIN_DC,PIN_SCE,PIN_RESET);
void setup() {
display.begin();
// init done
// you can change the contrast around to adapt the display
// for the best viewing!
display.setContrast(54);
randomSeed(analogRead(0));
delay(analogRead(3));
randomSeed(random(random(analogRead(0) + analogRead(1))));
display.display(); // show splashscreen
delay(1000);
display.clearDisplay(); // clears the screen and buffer
}
void loop() {
float a = random(1000.0) / 1000.0;
float b = 0.9998;
float c = 2.0 - 2.0 * a;
float j = 0.0;
float x = 0.0;
float y = (random(1000.0)/1000.0) * 12.0 + 0.1;
float z = 0.0;
float xp = 0.0;
float yp = 0.0;
for (int i = 0; i < 700; i++) {
z = x;
x = b * y + j;
j = a * x + c * pow(x,2) / (1 + pow(x,2));
y = j - z;
xp = (x * SIZECON) + 42;
yp = (y * SIZECON) + 24;
display.drawPixel(xp, yp, BLACK);
display.display();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment