Hi All,
Hopefully an easy one... when my code writes HIGH, the motor turns off, when LOW is written in turns on, the opposite should happen (& I swear was happening before). The HIGH/LOW is supposed to be controlling the PNP transistor on/off.
Any ideas I can try to fix?
int ledPina=3;
void setup()
{
pinMode(ledPina, OUTPUT);
}
void loop(){
digitalWrite(ledPina, HIGH);
delay(2500);
digitalWrite(ledPina, LOW);
delay(5000);
}
system
February 25, 2017, 1:28pm
2
You could post a schematic
Hi, If that's a PNP transistor then it's a "high side" switch, and the inverted operation is normal. Pulling the PNP base towards ground turns it on.
A schematic would make this clearer..
MarkT
February 25, 2017, 7:09pm
4
No fix needed, its functioning correctly. Perhaps your code would benefit from
#define ON LOW
#define OFF HIGH
to make things clearer.
Hi guys,
Thanks for the help, all working now. Yes, I hadn't understood how a PNP transistor works (my mistake).
& @MarkT , I input your code as the only change to get it working - now OFF = HIGH & the code is easy to follow & understand.
Thanks!