Hi everyone,
We have recently developed a kind of simple LEDs controller (just on/off - no PWM output) using PCA9655E, some MOSFETs, and teensy 3.2 as UART to i2c bridge.
The unit works as expected most of the time except the first when the power turns ON.
the current solution is to reprogram the teensy using the program button and after that everything is working well.
My guess is something on the initialization step of the expenders but I don't know.
same issue with other boards: UNO and PRO MINI.
thanks for the help,
yinon
We have recently developed a kind of simple LEDs controller (just on/off - no PWM output) using PCA9655E, some MOSFETs, and teensy 3.2 as UART to i2c bridge.
The unit works as expected most of the time except the first when the power turns ON.
the current solution is to reprogram the teensy using the program button and after that everything is working well.
My guess is something on the initialization step of the expenders but I don't know.
same issue with other boards: UNO and PRO MINI.
thanks for the help,
yinon
Code:
#include <Wire.h>
//#include <i2c_t3.h>
#include "pinsMap.h"
#include "blinkUnit.h"
#include "readInputUnit.h"
char colors[8]{'R','G','B','Y','P','T','W','C'};
bool States[BOARD_NUMBER*8+1]={0,0,0,0,0,0,0,0,0};
String inputString = "";
bool stringComplete = false;
bool gameOn=false;
char buff[20];
char *ptr0[2];
char *ptr1[2];
void pressEvent(int unit){
Serial.println(unit);
//Serial1.print(unit);
//Serial1.flush();
}
void setup() {
delay (100);
Serial.begin(9600);
//Serial1.begin(9600);
inputString.reserve(100);
pinMode(13,OUTPUT);
randomSeed(A0);
Wire.begin();
delay(100);
for(int i=0;i<=EXPENDERS_NUMBER-1;i++){
I2CSetValue(expAdd[i], PORT0_CONFIG, 0x88);
delay (10);
I2CSetValue(expAdd[i], PORT1_CONFIG, 0x88);
delay (10);
I2CSetValue(expAdd[i], OUTPUT_PORT0, 0x00);
delay (10);
I2CSetValue(expAdd[i], OUTPUT_PORT1, 0x00);
delay (10);
}
delay(100);
blinkAllUnits('R');
delay(550);
blinkAllUnits('C');
delay(550);
while(1){
for (int d=1; d<=8 ; d++ ) {
blinkUnit(d,'G');
Serial.println(d);
delay(250);
}
blinkAllUnits('C');
delay(550);
}
}
void loop() {
if (stringComplete) {
Serial.println(inputString);
inputString.toCharArray(buff,20);
*ptr0 = strtok(buff,":"); //set unit
int unit=atoi(*ptr0);
*ptr1 = strtok(NULL, ":"); //set color
char color=*ptr1[0];
if(unit==0)
blinkAllUnits(color);
else blinkUnit(unit,color);
inputString = "";
stringComplete = false;
}
while (Serial.available()){
char inChar = (char)Serial.read();
if (inChar == '\n')
stringComplete = true;
else inputString += inChar;
}
scanInputs();
}