ZTiK.nl
Well-known member
Hi again
I am trying to turn on 2 leds using an MCP23016, but I haven't been able to get them working yet.
I have connected everything like this example states.
I connected the bottom blue wire to SCL/pin A5 and the top blue wire to SDA/pin A4
When I remove the lines from pin 23 & 24 on the MCP23016 and connect a jumper between the 3.3v and the two resistors, the leds turn on, so the leds must work.
To make them light up, I am using the following code:
This example was supplied by iPrototype (where I bought the expander) and can be found here. (contains some more dutch comments though)
If I understand the process right, both lights should light up one after the other and each lights for a period of 500ms
It should be pretty straight-forward so I don't see where I am going wrong...
I have been using the supplied resistor/condensator, but I do notice that the condensator looks a bit different and is not blue as the product description suggests.
Am I wrong in using the supplied parts, are these meant for 5v perhaps?
Resistor 3K9 Ohm
Condensator 33 pF
I am trying to turn on 2 leds using an MCP23016, but I haven't been able to get them working yet.
I have connected everything like this example states.
I connected the bottom blue wire to SCL/pin A5 and the top blue wire to SDA/pin A4
When I remove the lines from pin 23 & 24 on the MCP23016 and connect a jumper between the 3.3v and the two resistors, the leds turn on, so the leds must work.
To make them light up, I am using the following code:
Code:
#include <Wire.h>;
#include <inttypes.h>;
void setup()
{
Wire.begin(); //Initialisatie van de wire klasse
sendData(0x06, 0x00); //binair 00000110, 00000000 //Zet alle 8 poorten op GP0 op output
sendData(0x07, 0x00); //binair 00000111, 00000000 //Zet alle 8 poorten op GP1 op output
}
void loop()
{
sendData(0x00, 0x04); //binair 00000000, 00000100 //zet poort 2 van GP0 hoog, de rest laag, pin 23 van de MCP23016 (GP0.2)
Serial.println("sendData(0x00, 0x04);");
delay(500); //wacht 500 ms
sendData(0x00, 0x08); //binair 00000000, 00001000 //zet poort 3 van GP0 hoog, de rest laag, pin 24 van de MCP23016 (GP0.3)
Serial.println("sendData(0x00, 0x08);");
delay(500); //wacht 500 ms
}
void sendData(uint8_t byte1, uint8_t byte2)
{
Wire.beginTransmission(0x20);
Wire.send(byte1);
Wire.send(byte2);
Wire.endTransmission();
}
If I understand the process right, both lights should light up one after the other and each lights for a period of 500ms
It should be pretty straight-forward so I don't see where I am going wrong...
I have been using the supplied resistor/condensator, but I do notice that the condensator looks a bit different and is not blue as the product description suggests.
Am I wrong in using the supplied parts, are these meant for 5v perhaps?
Resistor 3K9 Ohm
Condensator 33 pF