Hey Im trying to interface with the Glocal Camera trigger, basically another arduino with a opto switch for triggering a camera with sound. I have connected one wire from the switch to ground and one to digital input 10. Hoever all i get is 111111111111..... in the serial viewer. Can anyone help me out?
int timer = 100; // The higher the number, theslower the timing.
int pins[] = {2, 3, 4, 5, 6, 7, 8, 9}; // an array of pin numbers
int num_pins = 8; // the number of pins (i.e. the length of the array)
int inPin = 10;
int val = 0;
void setup()
{
Serial.begin(9600);
pinMode (inPin, INPUT); //sets the digital pin 10 to input
digitalWrite (inPin, HIGH);
int i;
for (i = 0; i < num_pins; i++) // the array elements are numbered from 0 to num_pins - 1
pinMode(pins*, OUTPUT); // set each pin as an output* } void loop() { val = digitalRead(inPin); Serial.print(val); int i; if (inPin = HIGH) {
for (i = 0; i < num_pins; i++) { // loop through each pin...*
_ digitalWrite(pins*, HIGH); // turning it on,_
_ delay(timer); // pausing,_ _ digitalWrite(pins, LOW); // and turning it off. } } else if (inPin = LOW) {_ for (i = num_pins - 1; i >= 0; i--) { _ digitalWrite(pins, HIGH); delay(timer); digitalWrite(pins, LOW); } } }*_
I found the problem. Well you guys did.... it was the switch it was badly soldered. Now I get 1111111...... when the switch is not in use and a 000000000...... when it is.