I am new with Arduino and I'm working on a school project that dim a LED panel using an app MIT app inventor. I created three level of brightness (High, Med, Low) each representing (75%, %50%, 25% duty cycle). Also I added an increase and decrease button by 10% (still working on it).
When I connected the oscilloscope to the circuit and pressed High button (75% duty cycle) I am getting a flipped signal same as when I press Low button (25% duty cycle). I used a npn transistor (PN2222) the base to 1K to Arduino pin 9, emitter to ground, and collector to Dim+ of panel and Dim- to ground of Arduino.
Is it correct that the signal is flipped or is there something missing. I tried it on another scope and its still giving me a flipped signal. Would appreciate any ideas or thoughts
I attached a screenshot of the scope when High button is pressed.
int panel1 = 9;
int x = 0;
int y = 0;
void setup() {
Serial.begin(9600);
pinMode(panel1, OUTPUT);
}
void loop() {
if(Serial.available() > 0)
{
int received = Serial.read();
Serial.println (received);
if (received == '1') // if High is clicked
{
analogWrite(panel1, 191); // 75% duty cycle
x = 191;
y = 191;
}
else if (received == '2') // if Med is clicked
{
analogWrite(panel1, 127); // 50% duty cycle
x = 127;
y = 127;
}
else if (received == '3') // if Low is clicked
{
analogWrite(panel1, 64); // 25% duty cycle
x = 64;
y = 64;
}
if (received == '4') // if increase is clicked increment by 10%
{
int newx = x - 13;
analogWrite(panel1, newx);
x = newx;
if (newx <= 217)
{
x = 271;
}
}
}
if (received == '5') // if decrease is clicked decrement by 10%
{
int newy = y + 13;
analogWrite(panel1, newy);
y = newy;
if (newy >= 38)
{
y = 38
}
}
}