8176Patrick:
Can i use the 1 entry to trigger an output voltage on another pin, so pulses occur all in synch?
If you want all that to happen on the same Arduino then there is no need to get data from the Serial Monitor because the Arduino already had the data before it sent it to the Serial Monitor.
And, yes, based on the limited information you have provided I reckon you can use the 1s to trigger something else.
Perhaps you just need some code like this
if (sensorValue == 1) {
// do something
}
By the way it is much easier for people to help you if you include short programs in your Post - like this
const int digitalInPin = 12; // input pin:
const int digitalOutPin = 9; // output pin led:
int sensorValue = 0; // value read from input pin:
int outputValue = 0; // value output to the PWM
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// read the analogue value
sensorValue = digitalRead(digitalInPin); //map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 55); // change the analog out value:
digitalWrite(digitalOutPin,outputValue);
// print the results:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output =");
Serial.println(outputValue);
//wait 2:
delay(2);
}
I've been thinking about whether there's a simpler way of getting the result I need:
Basically, whenever the cog stops rotating in its cycle, I'd like to trigger a camera exposure. I wonder if the code could simply detect either a high or low voltage, as the voltage cycle (going into the transistor) is one that goes from high (driving the cog rotation) to low (stopping it).
My attempt to re-write a simpler version would be as follows,
This is mainly based on amateur guesswork:) If there's an obvious flaw here, I'd be really grateful for any corrections, or explanations why this won't work
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
} // read the voltage relayed across the transistor
pinMode(analogInPin, INPUT);
pinMode(analogOutPin, OUTPUT);
void loop() {
// read the transistor output voltage
if (analogInPin, HIGH){analogWrite(analogOutpin, LOW);
}
else (analogWrite(analogOutpin, HIGH);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(inpin, INPUT);
pinMode(outpin, OUTPUT);
}
// read the voltage relayed across the transistor
void loop() {
// read the transistor output voltage
inpinState = digitalRead(inPin);
if (inpinState == HIGH) {
digitalWrite(outpin, LOW);
}
else {
digitalWrite(outpin, HIGH);
}
} >