Advertisement
learnelectronics

Nano Board tester

Jul 14th, 2020
1,987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*********************************************************************
  2. Learnelectronics
  3. Arduino Nano Experimentor's Board Test Script
  4. July 14,2020
  5. https://www.youtube.com/learnelectronics
  6. *********************************************************************/
  7.  
  8. #include <SPI.h>
  9. #include <Wire.h>
  10. #include <Adafruit_GFX.h>
  11. #include <Adafruit_SSD1306.h>
  12.  
  13. #define OLED_RESET 4
  14. Adafruit_SSD1306 display(OLED_RESET);
  15.  
  16. #define NUMFLAKES 10
  17. #define XPOS 0
  18. #define YPOS 1
  19. #define DELTAY 2
  20.  
  21.  
  22. #define LOGO16_GLCD_HEIGHT 16
  23. #define LOGO16_GLCD_WIDTH  16
  24. static const unsigned char PROGMEM logo16_glcd_bmp[] =
  25. { B00000000, B11000000,
  26.   B00000001, B11000000,
  27.   B00000001, B11000000,
  28.   B00000011, B11100000,
  29.   B11110011, B11100000,
  30.   B11111110, B11111000,
  31.   B01111110, B11111111,
  32.   B00110011, B10011111,
  33.   B00011111, B11111100,
  34.   B00001101, B01110000,
  35.   B00011011, B10100000,
  36.   B00111111, B11100000,
  37.   B00111111, B11110000,
  38.   B01111100, B11110000,
  39.   B01110000, B01110000,
  40.   B00000000, B00110000 };
  41.  
  42. #if (SSD1306_LCDHEIGHT != 64)
  43. #error("Height incorrect, please fix Adafruit_SSD1306.h!");
  44. #endif
  45.  
  46. void setup()   {                
  47.   Serial.begin(9600);
  48.  
  49.   // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  50.   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  51.   // init done
  52.  
  53.   // Show image buffer on the display hardware.
  54.   // Since the buffer is intialized with an Adafruit splashscreen
  55.   // internally, this will display the splashscreen.
  56.   display.display();
  57.   delay(2000);
  58.  
  59.   // Clear the buffer.
  60.   display.clearDisplay();
  61.  
  62.   pinMode(5,OUTPUT);
  63.   pinMode(6,OUTPUT);
  64.   pinMode(9,OUTPUT);
  65.  
  66.   pinMode(4,INPUT);
  67.   pinMode(7,INPUT);
  68.   pinMode(8,INPUT);
  69.  
  70.   digitalWrite(5,LOW);
  71.   digitalWrite(6,LOW);
  72.   digitalWrite(9,LOW);
  73.  
  74.  
  75. }
  76.  
  77. void loop() {
  78.  
  79. display.clearDisplay();
  80. display.setCursor(0,0);
  81. display.setTextSize(2);
  82. display.setTextColor(WHITE);
  83. display.print("hola");
  84. display.display();
  85.  
  86. Serial.print(digitalRead(4));
  87.  
  88.  
  89. if (digitalRead(4)==0){
  90.   digitalWrite(5,HIGH);
  91.   delay(10);
  92. }
  93. else{
  94.   digitalWrite(5,LOW);
  95. }
  96.  
  97. if (digitalRead(7)==0){
  98.   display.clearDisplay();
  99. display.setCursor(0,0);
  100. display.setTextSize(2);
  101. display.setTextColor(WHITE);
  102. display.print("D7 is low");
  103. display.display();
  104. delay(500);
  105. }
  106.  
  107. if (digitalRead(8)==0){
  108.  
  109.   digitalWrite(6,HIGH);
  110.   delay(50);
  111.   digitalWrite(6,LOW);
  112.   digitalWrite(9,HIGH);
  113.   delay(50);
  114.   digitalWrite(9,LOW);
  115.  
  116.   digitalWrite(6,HIGH);
  117.   delay(50);
  118.   digitalWrite(6,LOW);
  119.   digitalWrite(9,HIGH);
  120.   delay(50);
  121.   digitalWrite(9,LOW);
  122.  
  123.   digitalWrite(6,HIGH);
  124.   delay(50);
  125.   digitalWrite(6,LOW);
  126.   digitalWrite(9,HIGH);
  127.   delay(50);
  128.   digitalWrite(9,LOW);
  129.   digitalWrite(6,HIGH);
  130.   delay(50);
  131.   digitalWrite(6,LOW);
  132.   digitalWrite(9,HIGH);
  133.   delay(50);
  134.   digitalWrite(9,LOW);
  135.   digitalWrite(6,HIGH);
  136.   delay(50);
  137.   digitalWrite(6,LOW);
  138.   digitalWrite(9,HIGH);
  139.   delay(50);
  140.   digitalWrite(9,LOW);
  141.   digitalWrite(6,HIGH);
  142.   delay(50);
  143.   digitalWrite(6,LOW);
  144.   digitalWrite(9,HIGH);
  145.   delay(50);
  146.   digitalWrite(9,LOW);
  147. }
  148. else{
  149.   digitalWrite(5,LOW);
  150. }
  151.  
  152.  
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement