jagomart
digital resources
picture1_Arduino Code Pdf 191444 | Arduino Uno Rtd Sample Code


 130x       Filetype PDF       File size 0.51 MB       Source: www.openhacks.com


File: Arduino Code Pdf 191444 | Arduino Uno Rtd Sample Code
arduino uno rtd sample code revised 3 31 16 this code was written to be easy to understand code efficiency was not considered modify this code as you see fit ...

icon picture PDF Filetype PDF | Posted on 04 Feb 2023 | 2 years ago
Partial capture of text on file.
                                                     Arduino Uno
                                                     RTD Sample Code
                                                     Revised 3/31/16
                                                                                //This code was written to be easy to understand.
                                                                                //Code efficiency was not considered.
                                                                                //Modify this code as you see fit.
                                                                                //This code will output data to the Arduino serial monitor.
                                                                                //Type commands into the Arduino serial monitor to control the RTD temperature circuit.
                                                                                //This code was written in the Arduino 1.6.7 IDE
                                                                                //An Arduino UNO was used to test this code.
                                                                                                                                            GND 13  12   11  10  9    8     7    6   5   4   3    2   1   0
                                                                                                    RESET                               AREF
                                                                                                                                                                          DIGITAL (PWM=         )     TX0 RX0
                                                                                                                       ICSP2            L
                                                                                                                                      TX                                                             ON
                                                                                                                                      RX             Arduino          TM
                                                                                                                                                                                                     1
                                                                                                                                                                                                       ICSP
                                              centersheild
                                                                                                                                                                      POWER                 ANALOG IN
                                               BNC                                                                                                 IOREFRESET3V35V  GND GND VIN      A0  A1  A2   A3  A4  A5
       #include                                           //we have to include the SoftwareSerial library, or else we can't use it
       #define rx 2                                                         //define what pin rx is going to be
       #define tx 3                                                         //define what pin tx is going to be
       SoftwareSerial myserial(rx, tx);                                     //define how the soft serial port is going to work
       String inputstring = "";                                             //a string to hold incoming data from the PC
       String sensorstring = "";                                            //a string to hold the data from the Atlas Scientific product
       boolean input_string_complete = false;                               //have we received all the data from the PC
       boolean sensor_string_complete = false;                              //have we received all the data from the Atlas Scientific product
       float temperature;                                                   //used to hold a floating point number that is the RTD temperature
       void setup() {                                                       //set up the hardware
         Serial.begin(9600);                                                //set baud rate for the hardware serial port_0 to 9600
         myserial.begin(9600);                                              //set baud rate for the software serial port to 9600
         inputstring.reserve(10);                                           //set aside some bytes for receiving data from the PC
         sensorstring.reserve(30);                                          //set aside some bytes for receiving data from Atlas Scientific product
       }
       void serialEvent() {                                                 //if the hardware serial port_0 receives a char
         inputstring = Serial.readStringUntil(13);                          //read the string until we see a 
         input_string_complete = true;                                      //set the flag used to tell if we have received a completed string from the PC
       }
       void loop() {                                                        //here we go...
         if (input_string_complete) {                                       //if a string from the PC has been received in its entirety
           myserial.print(inputstring);                                     //send that string to the Atlas Scientific product
           myserial.print('\r');                                            //add a  to the end of the string
           inputstring = "";                                                //clear the string
           input_string_complete = false;                                   //reset the flag used to tell if we have received a completed string from the PC
         }
         if (myserial.available() > 0) {                                    //if we see that the Atlas Scientific product has sent a character
           char inchar = (char)myserial.read();                             //get the char we just received
           sensorstring += inchar;                                          //add the char to the var called sensorstring
           if (inchar == '\r') {                                            //if the incoming character is a 
             sensor_string_complete = true;                                 //set the flag
           }
         }
         if (sensor_string_complete == true) {                              //if a string from the Atlas Scientific product has been received in its entirety
           Serial.println(sensorstring);                                    //send that string to the PC's serial monitor
           if (isdigit(sensorstring[0])) {                                  //if the first character in the string is a digit
             temperature = sensorstring.toFloat();                          //convert the string to a floating point number so it can be evaluated by the Arduino
             if (temperature >= 25.0) {                                     //if the RTD temperature is greater than or equal to 25 C
               Serial.println("high");                                      //print "high" this is demonstrating that the Arduino is evaluating the RTD temperature
             }                                                              //as a number and not as a string
             if (temperature <= 24.999) {                                   //if the RTD temperature is less than or equal to 24.999 C
               Serial.println("low");                                       //print "low" this is demonstrating that the Arduino is evaluating the RTD temperature
             }                                                              //as a number and not as a string
           }
           sensorstring = "";                                               //clear the string
           sensor_string_complete = false;                                  //reset the flag used to tell if we have received a completed string from the 
         }                                                                  //Atlas Scientific product
       }
          Click here to download the *.ino file
       Atlas-Scientific.com                                                                                                          Copyright © Atlas Scientific LLC    All Rights Reserved
The words contained in this file might help you see if this file matches what you are looking for:

...Arduino uno rtd sample code revised this was written to be easy understand efficiency not considered modify as you see fit will output data the serial monitor type commands into control temperature circuit in ide an used test gnd reset aref digital pwm tx rx icsp l on tm centersheild power analog bnc iorefresetvv vin a include we have softwareserial library or else can t use it define what pin is going myserial how soft port work string inputstring hold incoming from pc sensorstring atlas scientific product boolean input complete false received all sensor float floating point number that void setup set up hardware begin baud rate for software reserve aside some bytes receiving serialevent if receives char readstringuntil read until true flag tell completed loop here go has been its entirety print send r add end of clear available sent character inchar get just var called println s isdigit first digit tofloat convert so evaluated by greater than equal c high demonstrating evaluating and...

no reviews yet
Please Login to review.