Teensy 3.2 arduino 1.8.9 teensydino 1.46
Could not get serial monitor working and discovered why.
Program simply compares 9 analog inputs(connected to light sensors) to a setpoint (pot) connected to analog "0"
each analog input is pared with a digital output using pins 1-9 set as pinmode "output"
This works, each output is connected to a BI color led with a simple circuit to have red on when low and green on with high
Problem,
attempted to monitor all the input analog values with the serial monitor and got no display.
with other 3.2 just plugged into usb (no pins connected) same code, it worked
Discovered that when the analog input value was higher than the setpoint when it sets the output pin high,
it stops the serial monitor
thinking it might be interfering with the hardware serial ports those outputs were disabled with no change
seems a logic high level(program generated) on any of the pins 1-9 stops the serial monitor
Question,
is there a different way to configure pins to be outputs?
Thank you
ScottW
the code. sure it's not the best way to do this(not a programmer)
Could not get serial monitor working and discovered why.
Program simply compares 9 analog inputs(connected to light sensors) to a setpoint (pot) connected to analog "0"
each analog input is pared with a digital output using pins 1-9 set as pinmode "output"
This works, each output is connected to a BI color led with a simple circuit to have red on when low and green on with high
Problem,
attempted to monitor all the input analog values with the serial monitor and got no display.
with other 3.2 just plugged into usb (no pins connected) same code, it worked
Discovered that when the analog input value was higher than the setpoint when it sets the output pin high,
it stops the serial monitor
thinking it might be interfering with the hardware serial ports those outputs were disabled with no change
seems a logic high level(program generated) on any of the pins 1-9 stops the serial monitor
Question,
is there a different way to configure pins to be outputs?
Thank you
ScottW
the code. sure it's not the best way to do this(not a programmer)
Code:
int setpoint = A0;
int setval = 0;
int optA = A1;
int optB = A2;
int optC = A3;
int optD = A4;
int optE = A5;
int optF = A6;
int optG = A7;
int optH = A8;
int optI = A9;
int luxA = 0;
int luxB = 0;
int luxC = 0;
int luxD = 0;
int luxE = 0;
int luxF = 0;
int luxG = 0;
int luxH = 0;
int luxI = 0;
int ledA = 1;
int ledB = 2;
int ledC = 3;
int ledD = 4;
int ledE = 5;
int ledF = 6;
int ledG = 7;
int ledH = 8;
int ledI = 9;
void setup() {
analogReadResolution(12);
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(ledC, OUTPUT);
pinMode(ledD, OUTPUT);
pinMode(ledE, OUTPUT);
pinMode(ledF, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledH, OUTPUT);
pinMode(ledI, OUTPUT);
Serial.begin(9600);
}
void loop() {
setval = analogRead(setpoint);
luxA = analogRead(optA);
if ( luxA >= setval) {digitalWrite(ledA, HIGH);
}
else {digitalWrite(ledA, LOW);
}
luxB = analogRead(optB);
if ( luxB >= setval) {digitalWrite(ledB, HIGH);
}
else {digitalWrite(ledB, LOW);
}
luxC = analogRead(optC);
if ( luxC >= setval) {digitalWrite(ledC, HIGH);
}
else {digitalWrite(ledC, LOW);
}
luxD = analogRead(optD);
if ( luxD >= setval) {digitalWrite(ledD, HIGH);
}
else {digitalWrite(ledD, LOW);
}
luxE = analogRead(optE);
if ( luxE >= setval) {digitalWrite(ledE, HIGH);
}
else {digitalWrite(ledE, LOW);
}
luxF = analogRead(optF);
if ( luxF >= setval) {digitalWrite(ledF, HIGH);
}
else {digitalWrite(ledF, LOW);
}
luxG = analogRead(optG);
if ( luxG >= setval) {digitalWrite(ledG, HIGH);
}
else {digitalWrite(ledG, LOW);
}
luxH = analogRead(optH);
if ( luxH >= setval) {digitalWrite(ledH, HIGH);
}
else {digitalWrite(ledH, LOW);
}
luxI = analogRead(optI);
if ( luxI >= setval) {digitalWrite(ledI, HIGH);
}
else {digitalWrite(ledI, LOW);
Serial.print(luxA);
Serial.print("\t");
Serial.print(luxB);
Serial.print("\t");
Serial.print(luxC);
Serial.print("\t");
Serial.print(luxD);
Serial.print("\t");
Serial.print(luxE);
Serial.print("\t");
Serial.print(luxF);
Serial.print("\t");
Serial.print(luxG);
Serial.print("\t");
Serial.print(luxH);
Serial.print("\t");
Serial.print(luxI);
Serial.print("\t");
Serial.print(setval);
Serial.print("\t");
Serial.println();
delay(100);
}
}
Last edited by a moderator: