summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/i2ccheck.cpp.q51
-rw-r--r--src/main.cpp62
2 files changed, 113 insertions, 0 deletions
diff --git a/src/i2ccheck.cpp.q b/src/i2ccheck.cpp.q
new file mode 100644
index 0000000..f849ba1
--- /dev/null
+++ b/src/i2ccheck.cpp.q
@@ -0,0 +1,51 @@
+#include <Wire.h>
+#include <Arduino.h>
+
+void setup() {
+ Wire.begin();
+
+ Serial.begin(9600);
+ while (!Serial); // Leonardo: wait for serial monitor
+ Serial.println("\nI2C Scanner");
+}
+
+void loop() {
+ byte error, address;
+ int nDevices;
+
+ Serial.println("Scanning...");
+
+ nDevices = 0;
+ for (address = 1; address < 127; address++ )
+ {
+ // The i2c_scanner uses the return value of
+ // the Write.endTransmisstion to see if
+ // a device did acknowledge to the 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(" !");
+
+ 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); // wait 5 seconds for next scan
+}
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..ad04a67
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,62 @@
+#include <Arduino.h>
+//#include <Wire.h>
+#include <Adafruit_SSD1306.h>
+
+Adafruit_SSD1306 display(128, 64);
+
+uint8_t zz[]={
+ 0b11111111,
+ 0b11111111,
+ 0b11111111,
+
+ 0b11011001,
+ 0b11100010,
+ 0b01111111,
+
+ 0b10011010,
+ 0b10111010,
+ 0b10111111,
+
+ 0b11011101,
+ 0b11110110,
+ 0b10111111,
+
+ 0b11011010,
+ 0b10111010,
+ 0b10111111,
+
+ 0b10001100,
+ 0b11100011,
+ 0b00111111,
+
+ 0b11111111,
+ 0b11111111,
+ 0b11111111
+};
+
+void setup() {
+ digitalWrite(2, 0);
+ delay(500);
+ if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)){
+ digitalWrite(2, 1);
+ while (true);
+ }
+ //display.display();
+ //delay(2000);
+ //display.drawLine(10, 10, 20, 20,1);
+ display.clearDisplay();
+
+ display.drawBitmap(80, 0, zz, 24,7,1);
+ //display.setCursor(35,30);
+ //display.setTextColor(2);
+ //display.println("Cicho\xa4\xb0\xb1\xb2");
+
+ display.display();
+}
+
+void loop() {
+ //digitalWrite(2, 0);
+ //delay(1000);
+ //digitalWrite(2, 1);
+ //delay(1000);
+} \ No newline at end of file