Go Down

Topic: TX light on, what does this mean? (Read 9047 times) previous topic - next topic

substance

I have uploaded my sketch to the board and that seemed to pass with no problems ( although my sketch is not working ) But the TX light on my board is illuminated and I do not know what this is for ( yes I am a newb so please be gentle  :) )
Could anyone give me some pointers please?

3dprinter

If nothing is broken, and you have not done strange wiring to pin1 or 0, then it means your sketch contains some Serial.print() and it is sending.... am I close? Put diagram&code in the next post

mcb1

substance
What sketch (use the code icon # above to post it....copy your code using edit - copy for forum, the click the code icon and paste it between.)

If your sketch has Serial.print in it, it could be sending flat out.
Use Serial monitor and set the baud rate to the same as in the Serial.begin(xxxxx).

The other option is that you have set digital pin1 to High either by calling something ie
const int PumpOut = 1;              // Pin 1  Pump Relay Output
pinMode(PumpOut, OUTPUT);     //usually in void setup() tells it that its an output
and then setting it ie
digitalWrite(PumpOut, HIGH);        // Turn On the PumpOut pin

or just
pinMode(1, OUTPUT);                 //usually in void setup() tells it that its an output
and digitalwrite (1, HIGH);

Hope this helps
Mark

substance

Code: [Select]
//pin for which tmp 35 sensor inputs into the arduino uno
int TMP_35_IN_A3 = 3;
//now to declare integers of any other peripherals
//red pin connection
int RED_ALARM = 9;
//yellow pin connection
int YELLOW_ALARM = 8;
//green pin connection
int GREEN_ALARM = 9;
//buzzer alarm connection
int BUZZ_PWM_ALARM = 4;



void setup()
{
  Serial.begin(9600);  //this is how the chip communicates with the PC
    //set ALARMS pins as output
  pinMode(RED_ALARM, OUTPUT);
  pinMode(YELLOW_ALARM, OUTPUT);
  pinMode(GREEN_ALARM, OUTPUT);
  pinMode(BUZZ_PWM_ALARM, OUTPUT);
    //setting the reference voltage to the default setting
  analogReference(DEFAULT);
}
void loop()
{
  long aRead = 0; //assumes voltage range from input
    float voltage; //declares a floating number of the voltage
   // uses a for statement to count up to 10 readings
  // which will limit fluctuations when averaged out
  for(int i=0; i < 10; i++)
    aRead += analogRead(TMP_35_IN_A3); //reads the value from tmp sensor
     aRead = aRead / 10; //now takes the average of 10 readings
       //this performs the analog to digital conversion
    voltage = (aRead * 5.0) / 1024.0;
      //converts to millivolts
    voltage = voltage * 1000;
    //temp less than 30 degrees Celsius (30mV)
    if( voltage <= 300 )
    {
      digitalWrite(GREEN_ALARM, HIGH); //turn on green alarm
      digitalWrite(YELLOW_ALARM, LOW); //turn off yellow alarm
      digitalWrite(RED_ALARM, LOW); //turn off red alarm
      digitalWrite(BUZZ_PWM_ALARM, LOW); //turn off buzzer
    }
    else if( voltage <= 310 ) //voltage between 30 degrees and 31 degrees               
                                              //Celsius turn red and yellow on
    {         
      digitalWrite(GREEN_ALARM, HIGH); //turn on green alarm
      digitalWrite(YELLOW_ALARM, HIGH); //turn on yellow alarm
      digitalWrite(RED_ALARM, LOW); //turn off red alarm
      digitalWrite(BUZZ_PWM_ALARM, LOW); //turn off buzzer
    }
    else if( voltage <= 315) //voltage less that 31.5 degrees Celsius   
    {
      digitalWrite(GREEN_ALARM, LOW); //turns off green alarm
      digitalWrite(YELLOW_ALARM, HIGH); //turns on yellow alarm
      digitalWrite(RED_ALARM, LOW); //turns off red alarm
      digitalWrite(BUZZ_PWM_ALARM, LOW); //turns off buzzer
    }
    else if( voltage <= 320) //voltage less that 32 degrees Celsius   
    {
      digitalWrite(GREEN_ALARM, LOW); //turns off green alarm
      digitalWrite(BUZZ_PWM_ALARM, LOW); //turns off buzzer
      digitalWrite(RED_ALARM, HIGH); //turns on red alarm
      digitalWrite(YELLOW_ALARM, HIGH); //turns on yellow alarm
      delay(200); //delays for 200mS
      digitalWrite(YELLOW_ALARM, LOW); //turns off yellow alarm
      delay(200); //delays for 200mS
    }
    else if( voltage <= 330) //voltage less that 33 degrees Celsius   
    {
      digitalWrite(GREEN_ALARM, LOW); //turns off green alarm
      digitalWrite(YELLOW_ALARM, LOW); //turns off yellow alarm
      digitalWrite(RED_ALARM, HIGH); //turns on red alarm
      analogWrite(BUZZ_PWM_ALARM, 128); //turns on buzzer
      delay(500); //delays for 200mS
      digitalWrite(BUZZ_PWM_ALARM, LOW); //turns off buzzer
      delay(200); //delays for 200mS
     }
     else // anything above 33 degrees Celsius
     {
      digitalWrite(GREEN_ALARM, LOW); //turns off green alarm
      digitalWrite(YELLOW_ALARM, LOW); //turns off yellow alarm
      digitalWrite(RED_ALARM, LOW); //turns off red alarm
      analogWrite(BUZZ_PWM_ALARM, 254); //turns on buzzer
     }
//print debug info to serial console
    Serial.print("Analog: ");
    Serial.print(aRead);
    Serial.print(" Voltage:");
    Serial.println(voltage);
       //short 1 sec delay between measurements
    delay(1000);
}



Here you go lads, thanks for your help. Could you point me in the right dirstion from my code?

3dprinter

As we are now not talking about the Arduino working or not, but your sketch code, I suggest you repost in the Programming or Sensors (put a small post here that this thread is closed)

On casual reading your code seems OK, so perhaps the way you connect your the analog value is wrong. Include a circuit diagram. You measure (typical) 300mv, which you scale correct assuming a 5V range on the input. That means analogRead returns 61 for 297mV and 62 for 302mV and so on. You want to see the difference between 300 and 310mV. That is too narrow. The resolution of the ADC will be off by a +/-1 or 2 usually. Change your circuit to give a greater voltage range and/or look into changing the ARef value.

Your code does not need to convert to mV. No harm, but a roundabout way of doing it. Really you know that 30 degrees = 300mv = 61 on analogRead. (and 32=320=66) Use the map() function
Code: [Select]
degree=map(aRead, 61, 66, 30, 32) // The mapfunction will scale linearly also outside the given boundsNow your code can work in the "natural" unit of degrees which is what you want to trigger on. Of course, the values will be differnet once you rescale your input voltage - you can see the resoultion is not enough.

Lastly, and perhaps firstly and most importantly - when you open the Serial Monitor from the IDE, what values DOES it report?

Go Up