Created
January 20, 2018 21:18
-
-
Save Zerg00s/7c1d0b0dbec06480ca9862f4bd973bec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#include <Wire.h> | |
void setup() | |
{ | |
Wire.begin(); | |
Serial.begin(9600); | |
while (!Serial); | |
Serial.println("\nI2C Scanner"); | |
} | |
void loop() | |
{ | |
byte error, address; | |
int nDevices; | |
Serial.println("Scanning..."); | |
nDevices = 0; | |
for(address = 1; address < 120; address++ ) | |
{ | |
Wire.beginTransmission(address); | |
error = Wire.endTransmission(); | |
if (error == 0) | |
{ | |
Serial.print("I2C device found at address 0x"); | |
if (address<16) | |
Serial.print("0"); | |
Serial.print(address,HEX); | |
Serial.println(" !"); | |
DisplayGreeting(); | |
nDevices++; | |
} | |
else if (error==4) | |
{ | |
Serial.print("Unknown error at address 0x"); | |
if (address<16) | |
Serial.print("0"); | |
Serial.println(address,HEX); | |
} | |
} | |
if (nDevices == 0) | |
Serial.println("No I2C devices found\n"); | |
else | |
Serial.println("done\n"); | |
delay(5000); | |
} | |
void DisplayGreeting(){ | |
Serial.println("Showing stuff..."); | |
Adafruit_SSD1306 display(4); | |
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
display.setCursor(10,0); | |
display.clearDisplay(); | |
display.println("Greetings"); | |
display.display(); | |
delay(1); | |
display.startscrollright(0x00, 0x0F); | |
delay(500); | |
display.stopscroll(); | |
delay(500); | |
display.startscrollleft(0x00, 0x0F); | |
delay(500); | |
display.stopscroll(); | |
display.clearDisplay(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment