Code Aduino IDE
/////////////////ผนวกไลบรารี่จอแสดงผล//////////////////
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 OLED(-1);
//////////////////////////////////////////////////////
void setup() {
OLED.begin(SSD1306_SWITCHCAPVCC, 0x3C); // กำหนดแอดเดรสของพอร์ตจอเป็น 0x3C (for the 128x64)
}
void loop() {
/////////// ตั้งค่าเซนเซอร์ตามการอ่านพอร์ตอนาล็อก S0,S1,S2,S3
int s0 = analogRead(0);int s1 = analogRead(1);int s2 = analogRead(2);int s3 = analogRead(3);
int s4 = analogRead(4);int s5 = analogRead(5);int s6 = analogRead(6);int s7 = analogRead(7);
int s8 = analogRead(8);int s9 = analogRead(9);int s10 = analogRead(10);int s11 = analogRead(11);
int s12 = analogRead(12);int s13 = analogRead(13);int s14 = analogRead(14);int s15 = analogRead(15);
////////////////////////////////////////////////////////
OLED.clearDisplay();
OLED.setTextColor(WHITE, BLACK); //สีอักษรเป็นสีขาว ,พื้นหลังดำ
OLED.setCursor(0, 0); // เซตตำแหน่ง 0,0
// OLED.setTextSize(2); // เซตขนาดอักษรมีขนาดเป็น 2
// OLED.println("ROBOT CLUB"); // แสดงค่าข้อความ ROBOT CLUB
OLED.setTextSize(1); // เซตขนาดอักษรมีขนาดเป็น 1
OLED.print(" A0="); OLED.print(s0); // แสดงค่าเซนเซอร์ S0
OLED.print(" A1="); OLED.print(s1); // แสดงค่าเซนเซอร์ S1
OLED.print(" A2="); OLED.println(s2); // แสดงค่าเซนเซอร์ S2
OLED.print(" A3="); OLED.print(s3); // แสดงค่าเซนเซอร์ S3
OLED.print(" A4="); OLED.print(s4); // แสดงค่าเซนเซอร์ S4
OLED.print(" A5="); OLED.println(s5); // แสดงค่าเซนเซอร์ S5
OLED.print(" A6="); OLED.print(s6); // แสดงค่าเซนเซอร์ S6
OLED.print(" A7="); OLED.print(s7); // แสดงค่าเซนเซอร์ S7
OLED.print(" A8="); OLED.println(s8); // แสดงค่าเซนเซอร์ S8
OLED.print(" A9="); OLED.print(s9); // แสดงค่าเซนเซอร์ S9
OLED.print(" A10="); OLED.println(s10); // แสดงค่าเซนเซอร์ S10
OLED.print(" A11="); OLED.print(s11); // แสดงค่าเซนเซอร์ S11
OLED.print(" A12="); OLED.println(s12); // แสดงค่าเซนเซอร์ S12
OLED.print(" A13="); OLED.print(s13); // แสดงค่าเซนเซอร์ S13
OLED.print(" A14="); OLED.println(s14); // แสดงค่าเซนเซอร์ S14
OLED.display();
delay(100); // เปลี่ยนค่าเซนเซอร์ทุก 0.1 วินาที
}