Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Adafruit_GFX.h>
- #include <Adafruit_PCD8544.h>
- #define Pi 3.1415926535
- #define Deg *Pi/180
- // Using 3.3 volts power
- // Software SPI (slower updates, more flexible pin options):
- // pin 22 - Serial clock out (SCLK)
- // pin 23 - Serial data out (DIN)
- // pin 24 - Data/Command select (D/C)
- // pin 25 - LCD chip select (CS)
- // pin 26 - LCD reset (RST)
- Adafruit_PCD8544 display = Adafruit_PCD8544(22, 23, 24, 25, 26);
- int height = display.height();
- int width = display.width();
- int count = 0;
- void setup() {
- Serial.begin(9600);
- // init
- display.begin();
- display.setContrast(50);
- display.setTextSize(1);
- display.setTextColor(BLACK);
- display.setRotation(2); // because in this example we're using it upside down
- display.setCursor(0,0);
- display.clearDisplay();
- display.display();
- }
- void loop() {
- float r = min(height,width)/2-1;
- float theta = (float(count)*6-90) Deg;
- int x1 = int((r-2)*cos(theta)+width/2);
- int y1 = int((r-2)*sin(theta)+height/2);
- int x2 = int((r-7)*cos(theta+12 Deg)+width/2);
- int y2 = int((r-7)*sin(theta+12 Deg)+height/2);
- int x3 = int((r-7)*cos(theta-12 Deg)+width/2);
- int y3 = int((r-7)*sin(theta-12 Deg)+height/2);
- Serial.println(count);
- display.clearDisplay();
- display.setCursor(0,0);
- display.println(count);
- display.drawCircle(width/2, height/2, int(r), BLACK);
- display.drawLine(width/2, height/2, x1, y1, BLACK);
- display.fillTriangle(x1 ,y1, x2, y2, x3, y3, BLACK);
- display.display();
- delay(200);
- count=(count+1)%60;
- }
Advertisement
Add Comment
Please, Sign In to add comment