Advertisement
edofhell

Arduino Nokia 5510 test code

Feb 7th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <SPI.h>
  2.  
  3. // Nokia 5110 LCD-Display (84x48 Pixels)
  4. // English translation by ed nielsen - Darkgeej.dk
  5.  
  6. #include <Adafruit_GFX.h>
  7. #include <Adafruit_PCD8544.h>
  8.  
  9. // D7 - Serial clock out (CLK or SCLK)
  10. // D6 - Serial data out (DIN)
  11. // D5 - Data/Command select (DC or D/C)
  12. // D4 - LCD chip select (CE or CS)
  13. // D3 - LCD reset (RST)
  14. Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
  15.  
  16.  
  17. void setup() {
  18.  
  19. // Display initialisieren
  20. display.begin();
  21.  
  22. // Contrast setting
  23. display.setContrast(60);
  24. display.clearDisplay(); // clears the screen and buffer
  25. }
  26.  
  27.  
  28. void loop() {
  29.  
  30. display.setTextSize(1);
  31. set_text(11,0,"Hello world",BLACK);
  32. delay(500);
  33.  
  34. display.drawLine(7,11,77,11,BLACK);
  35. display.display();
  36. delay(500);
  37.  
  38. display.drawCircle(8,23,5,BLACK);
  39. display.display();
  40. delay(500);
  41.  
  42. display.fillCircle(11,26,5,BLACK);
  43. display.display();
  44. delay(500);
  45.  
  46. display.drawRect(25,18,10,10,BLACK);
  47. display.display();
  48. delay(500);
  49.  
  50. display.fillRect(28,21,10,10,BLACK);
  51. display.display();
  52. delay(500);
  53.  
  54. display.drawRoundRect(47,18,10,10,2,BLACK);
  55. display.display();
  56. delay(500);
  57.  
  58. display.fillRoundRect(50,21,10,10,2,BLACK);
  59. display.display();
  60. delay(500);
  61.  
  62. display.drawTriangle(68,18,68,28,78,23,BLACK);
  63. display.display();
  64. delay(500);
  65.  
  66. display.fillTriangle(71,21,71,31,81,26,BLACK);
  67. display.display();
  68. delay(500);
  69.  
  70. // A little bit scroll-text magic
  71. int x=0;
  72. for(int i=0;i<(5.6*8);i++){
  73. set_text(x,40,"darkgeej.dk",BLACK);
  74. delay(i==0?1000:100);
  75. if(i<(5.6*8)-1)set_text(x,40,"darkgeej.dk",WHITE);
  76. if((i)<(2.74*8))x-=1;else x+=1;
  77. }
  78. delay(250);
  79.  
  80. display.clearDisplay(); // Clear the display
  81. }
  82.  
  83. void set_text(int x,int y,String text,int color){
  84.  
  85. display.setTextColor(color); // Text color, so black or white
  86. display.setCursor(x,y); // Start point position of the texts
  87. display.println(text); // Output text line
  88. display.display(); // Update the display
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement