Program allows for a rectangle displayed on SSD1306-based OLED display to be moved by x- and y-axis uisng two user potentiometers.

Dependencies:   mbed Adafruit_GFX

Committer:
joe ellsworth
Date:
Sun Mar 20 21:39:52 2016 -0700
Revision:
7:5962e77516ac
Parent:
6:02a058f2ec6f
Child:
8:ead6147e31a4
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeata2wh 0:befb557584fb 1 /* Scan I2C bus on specified pins and prints out
joeata2wh 6:02a058f2ec6f 2 * the all address where an active device responds.
joeata2wh 0:befb557584fb 3 *
joeata2wh 0:befb557584fb 4 * By Joe Elsworth CTO of A2WH
joeata2wh 3:8def8fb70765 5 * Free use for all but no warranty, no promises.
joeata2wh 6:02a058f2ec6f 6 * Don't forget 3K pull-up resistors on sda,scl
joeata2wh 2:e90c47d4f358 7 *
joeata2wh 2:e90c47d4f358 8 * I tested this by soldering in a I2C chip known to respond at
joeata2wh 2:e90c47d4f358 9 * address dec=120 hex=70 and the utility got the ack as expected.
joeata2wh 2:e90c47d4f358 10 * when the chip was de-soldered it was no longer detected.
joeata2wh 2:e90c47d4f358 11 */
joeata2wh 0:befb557584fb 12
joeata2wh 0:befb557584fb 13 #include "mbed.h"
joeata2wh 0:befb557584fb 14
joeata2wh 0:befb557584fb 15 Serial pc(USBTX, USBRX);
joe ellsworth 7:5962e77516ac 16 Serial pc2(USBTX, USBRX);
joeata2wh 0:befb557584fb 17
joeata2wh 1:2363995f603f 18 #define D_SDA PB_7
joeata2wh 0:befb557584fb 19 #define D_SCL PB_6
joeata2wh 0:befb557584fb 20 // sda=PB7, scl=PB_6 Pins specific to Nucleo-F303K8
joeata2wh 0:befb557584fb 21 // must change pins to match your board.
joeata2wh 0:befb557584fb 22
joeata2wh 0:befb557584fb 23 I2C i2c(D_SDA, D_SCL);
joeata2wh 0:befb557584fb 24
joeata2wh 0:befb557584fb 25 DigitalOut myled(LED1);
joeata2wh 0:befb557584fb 26
joeata2wh 4:ad1195c10812 27 int ack;
joeata2wh 6:02a058f2ec6f 28 int address;
joeata2wh 0:befb557584fb 29 void scanI2C() {
joeata2wh 0:befb557584fb 30 for(address=1;address<127;address++) {
joeata2wh 0:befb557584fb 31 ack = i2c.write(address, "11", 1);
joeata2wh 0:befb557584fb 32 if (ack == 0) {
joeata2wh 0:befb557584fb 33 pc.printf("\tFound at %3d -- %3x\r\n", address,address);
joeata2wh 0:befb557584fb 34 }
joeata2wh 0:befb557584fb 35 wait(0.05);
joeata2wh 0:befb557584fb 36 }
joeata2wh 0:befb557584fb 37 }
joeata2wh 0:befb557584fb 38
joeata2wh 0:befb557584fb 39 int main() {
joeata2wh 0:befb557584fb 40 pc.baud(9600);
joeata2wh 0:befb557584fb 41 pc.printf("I2C scanner \r\n");
joeata2wh 0:befb557584fb 42 scanI2C();
joeata2wh 0:befb557584fb 43 pc.printf("Finished Scan\r\n");
joeata2wh 5:a4fddd74263c 44 // just blink to let us know the CPU is alive
joeata2wh 0:befb557584fb 45 while(1) {
joeata2wh 0:befb557584fb 46 wait(5.0);
joeata2wh 0:befb557584fb 47 myled = !myled;
joeata2wh 0:befb557584fb 48 }
joeata2wh 0:befb557584fb 49 }
joeata2wh 0:befb557584fb 50