Ok, so I'm trying to trigger an event with a separate power source. The power source is a 5V/800mah wireless charging pad receiver. For simplicity sake, I'm wanting to turn an LED blue when there is no power running through the charging pad, and turn the LED Red when there is power running through the pad. The Arduino is on its own power and is not connected to the charging pad. So basically, its like I have a 5V/800mah battery with a switch on it. How would I connect it to the arduino and read whether a charge is going through it or not.
//LED colors
int bluePin=3;
int greenPin=5;
int redPin=6;
//Fade effect values
int brightGreen=1;
int brightRed=1;
int brightBlue=1;
int fade=1;
int fade2=1;
int fade3=1;
//Magnet prox(Switch) trigger values
int Switch=9;
int trigger;
void setup() {
pinMode(bluePin,OUTPUT);
pinMode(redPin,OUTPUT); //LED pinModes
pinMode(greenPin,OUTPUT);
pinMode(Switch,INPUT_PULLUP); //Switch pinModes
}
void loop() {
trigger=digitalRead(Switch);
if(trigger==1){
analogWrite(bluePin,brightBlue);
while(brightGreen>=1){
analogWrite(greenPin,brightGreen);
brightGreen=brightGreen-1;
delay(5);
}
while(brightRed>=1){
analogWrite(redPin,brightRed);
brightRed=brightRed-1;
delay(10);
}
while(brightBlue<=65){
analogWrite(bluePin,brightBlue);
brightBlue=brightBlue+1;
delay(20);
}
brightBlue=brightBlue+fade;
if(brightBlue<=65||brightBlue>=250){
fade=-fade;
}
delay(10);
}
if(trigger==0){
analogWrite(bluePin,brightBlue);
analogWrite(greenPin,brightGreen);
analogWrite(redPin,brightRed);
while(brightBlue>=1){
analogWrite(bluePin,brightBlue);
brightBlue=brightBlue-1;
delay(5);
}
while(brightRed<150){
analogWrite(redPin,brightRed);
brightRed=brightRed+5;
delay(10);
}
brightRed=brightRed-fade2;
if(brightRed<=150||brightRed>=250){
fade2=-fade2;
}
while(brightGreen<5){
analogWrite(greenPin,brightGreen);
brightGreen=brightGreen+1;
delay(10);
}
brightGreen=brightGreen+fade3;
if(brightGreen<=5||brightGreen>=10){
fade3=-fade3;
}
delay(100);
}
}
This is the code I am using, and I'm wanting to replace my current INPUT_PULLUP switch with the charging pad trigger. Please help!!