Show Posts
Pages: [1] 2
1  Using Arduino / Displays / Re: char waitForKey(); issue on: June 10, 2014, 07:16:45 pm
Works perfect now.  

Thanks Hackscribble your the best.  Sent some karma your way. 
2  Using Arduino / Displays / char waitForKey(); issue on: June 10, 2014, 12:32:26 pm
I wrote  a program to remotely control some relays.  I wanted the LCD to look like this.

Enter Box:
Enter Relay:

Then you enter the Box letter from the keypad and then it would prompt you for the relay number.  This way I could control multiple boxes.

The issue is it not working all the time.  I seem to be bouncing around sometimes it will enter the relay line first when I meant for it  
to enter the box number.  It seems to be skipping the char waitForKey(); sometimes.  

Transmitter Code:

Code:
#include <VirtualWire.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
 
 char *controller;
 
 int currentPosition = 0;

//define the keypad
const byte rows = 4;
const byte cols = 4;

char keys[rows][cols] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[rows] = {11,10,9,8};
byte colPins[cols] = {7,6,5,4};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

 
 
 
 
 void setup() {
   keypad.setDebounceTime(250);
   pinMode(13,OUTPUT);
   vw_set_ptt_inverted(true); //
   vw_set_tx_pin(12);
   vw_setup(4000);// speed of data transfer Kbps
   lcd.begin(16,2);
   lcd.backlight();
   lcd.setCursor(0, 0);
   displayScreen();
   Serial.begin(9600);
 
 }

 void loop(){
    
          // Box signal
    char key = keypad.getKey();
    char waitForKey();
     if (key != NO_KEY){
       if (key == '*'){
               controller="R"  ;    // Reset system
               digitalWrite(13, true);
               vw_send((uint8_t *)controller, strlen(controller));
               vw_wait_tx(); // Wait until the whole message is gone
               digitalWrite(13, false);
               displayScreen();
       }
         else {
              Serial.print(key);
              lcd.setCursor(12, 0);
              lcd.print(key);
              digitalWrite(13, true); // Flash a light to show transmitting
              vw_send((uint8_t *)&key, 1);
              vw_wait_tx(); // Wait until the whole message is gone
              digitalWrite(13, false);
          
        }
     }
             //Relay Signal
     char key1 = keypad.getKey();
     char waitForKey();
     if (key1 != NO_KEY){
         if (key1 == '*'){
               controller="R"  ; // Reset system
               digitalWrite(13, true);
               vw_send((uint8_t *)controller, strlen(controller));
               vw_wait_tx(); // Wait until the whole message is gone
               digitalWrite(13, false);
               displayScreen();
                 }
         else {
              Serial.print(key1);
              lcd.setCursor(12, 1);
              lcd.print(key1);
              digitalWrite(13, true); // Flash a light to show transmitting
              vw_send((uint8_t *)&key1, 1);
              vw_wait_tx(); // Wait until the whole message is gone
              digitalWrite(13, false);
              delay(1000);
              displayScreen();
              delay(1000);
              
                 }
           }
    
    
    

 }
 
 void displayScreen()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Enter Box:");
  lcd.setCursor(0,1);
  lcd.print("Enter Relay:");
}


Thank for any help
3  Using Arduino / Networking, Protocols, and Devices / Re: Sending keypad entries over 433mhz transmitter on: June 02, 2014, 01:26:49 pm
Looking at the RX code ...

Code:
    if (vw_get_message(buf, &buflen)) // Non-blocking
     {
       if(buf[0]=='A'){
        Serial.print(buf[0]);
        digitalWrite(13,1);
        vw_wait_rx();
          if(buf[0]=='1'){

The TX is sending one character per message, as you press a key on the keypad.  

So, I think the message in buf (when vw_get_message() returns true) will be 1 byte long.  

Then, if you sent 'A', I would expect the Serial.print and LED write to execute.

But then, vw_wait_rx will block until the next message is received with the next key press.  However, I think you need to call vw_get_message again at this point, otherwise the contents of buf will not be updated and the next if statement will never be true.

Could this be what you are seeing?

Ray


WOOHOO  did that and it works now.

Thank you very much!!   smiley-grin
4  Using Arduino / Networking, Protocols, and Devices / Re: Sending keypad entries over 433mhz transmitter on: June 02, 2014, 01:18:46 pm
Hi Phil

Quote
I did a simple test just having it an on off 0 or 1 without the keypad in a loop and it worked great. 

Can you please post the code that did work in this test?

Quote
When I implemented your suggestions and tried it with the keypad I am not receiving the keypad from the TX board.  The LED does not light nor does the serial print anything.

Can you clarify this - on the TX, did the correct key print on the serial monitor and the LED flash correctly?  And on the RX, you get nothing printed on serial monitor and no LED flashes?

Thanks

Ray


On the TX serial print I got the correct keypad entries and LED blink.   On the receive side when I press A on the TX keypad  the RX serial monitor prints 65.

here is the test code I used just to verify I was getting transmission and the relays would switch on and work.  This functioned fully.
test TX
Code:
#include <VirtualWire.h>
 char *controller;
 void setup() {
   pinMode(13,OUTPUT);
 vw_set_ptt_inverted(true); //
 vw_set_tx_pin(12);
 vw_setup(4000);// speed of data transfer Kbps
 }

 void loop(){
 controller="1"  ;
 vw_send((uint8_t *)controller, strlen(controller));
 vw_wait_tx(); // Wait until the whole message is gone
 digitalWrite(13,1);
 delay(2000);
 controller="0"  ;
 vw_send((uint8_t *)controller, strlen(controller));
 vw_wait_tx(); // Wait until the whole message is gone
 digitalWrite(13,0);
 delay(2000);

 }

test RX
Code:

#include <VirtualWire.h>

#define RELAY_ON 0
#define RELAY_OFF 1
#define Relay_1  2  // Arduino Digital I/O pin number
#define Relay_2  3
#define Relay_3  4
#define Relay_4  5
#define Relay_5  6
#define Relay_6  7
#define Relay_7  8
#define Relay_8  9
#define Reset  10


 void setup()
 {
     vw_set_ptt_inverted(true); // Required for DR3100
     vw_set_rx_pin(12);
     vw_setup(4000);  // Bits per sec
     pinMode(13, OUTPUT);

     vw_rx_start();       // Start the receiver PLL running
      //-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(Relay_1, RELAY_OFF);
  digitalWrite(Relay_2, RELAY_OFF);
  digitalWrite(Relay_3, RELAY_OFF);
  digitalWrite(Relay_4, RELAY_OFF);  
  digitalWrite(Relay_5, RELAY_OFF);
  digitalWrite(Relay_6, RELAY_OFF);
  digitalWrite(Relay_7, RELAY_OFF);
  digitalWrite(Relay_8, RELAY_OFF);  
  
//---( THEN set pins as outputs )----  
  pinMode(Relay_1, OUTPUT);  
  pinMode(Relay_2, OUTPUT);  
  pinMode(Relay_3, OUTPUT);  
  pinMode(Relay_4, OUTPUT);
  pinMode(Relay_5, OUTPUT);  
  pinMode(Relay_6, OUTPUT);  
  pinMode(Relay_7, OUTPUT);  
  pinMode(Relay_8, OUTPUT);
  pinMode(Reset, OUTPUT);
  
  delay(4000); //Check that all relays are inactive at Reset
 }
     void loop()
 {
     uint8_t buf[VW_MAX_MESSAGE_LEN];
     uint8_t buflen = VW_MAX_MESSAGE_LEN;

     if (vw_get_message(buf, &buflen)) // Non-blocking
     {
       if(buf[0]=='1'){

   digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
   delay(2000);
   digitalWrite(13,1);
       }  
    if(buf[0]=='0'){
   digitalWrite(13,0);
   digitalWrite(Relay_1, RELAY_OFF);
   delay(2000);
     }

 }
 }
  
5  Using Arduino / Networking, Protocols, and Devices / Re: Sending keypad entries over 433mhz transmitter on: June 02, 2014, 12:36:26 pm
Got my TX and RX boards today.  I did a simple test just having it an on off 0 or 1 without the keypad in a loop and it worked great. 

When I implemented your suggestions and tried it with the keypad I am not receiving the keypad from the TX board.  The LED does not light nor does the serial print anything.

TX Code: 
Code:
/simple Tx on pin D12
 //..................................
 
 
 #include <VirtualWire.h>
 #include <Wire.h>
 #include <LiquidCrystal_I2C.h>
 #include <Keypad.h>
 
 char *controller;
 
 int currentPosition = 0;
 char* ourCode = "1234";

//define the keypad
const byte rows = 4;
const byte cols = 4;

char keys[rows][cols] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[rows] = {11,10,9,8};
byte colPins[cols] = {7,6,5,4};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

 
 
 
 
 void setup() {
   pinMode(13,OUTPUT);
 vw_set_ptt_inverted(true); //
 vw_set_tx_pin(12);
 vw_setup(4000);// speed of data transfer Kbps
 lcd.init();  // initialize the lcd
   // Print a message to the LCD.
  lcd.backlight();
 
  displayScreen();
  Serial.begin(9600);
 
 }

 void loop(){
 
    char key = keypad.getKey();
    char waitForKey();
     if (key != NO_KEY){
    Serial.print(key);
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)&key, 1);
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
     }

 }
 
 void displayScreen()
{
  clearScreen();
  lcd.setCursor(0,0);
  lcd.print("Enter Code");
  lcd.setCursor(0,2);
  lcd.print("Enter:");
}

void clearScreen()
{
  lcd.setCursor(0,0);
  lcd.print("                    ");
  lcd.setCursor(0,1);
  lcd.print("                    ");
  lcd.setCursor(0,2);
  lcd.print("                    ");
  lcd.setCursor(0,3);
  lcd.print("                    ");
}

RX code:

Code:
#include <VirtualWire.h>
 
 
#define RELAY_ON 0
#define RELAY_OFF 1
#define Relay_1  2  // Arduino Digital I/O pin number
#define Relay_2  3
#define Relay_3  4
#define Relay_4  5
#define Relay_5  6
#define Relay_6  7
#define Relay_7  8
#define Relay_8  9
#define Reset  10

 
 
 
 void setup()
 {
   //-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(Relay_1, RELAY_OFF);
  digitalWrite(Relay_2, RELAY_OFF);
  digitalWrite(Relay_3, RELAY_OFF);
  digitalWrite(Relay_4, RELAY_OFF); 
  digitalWrite(Relay_5, RELAY_OFF);
  digitalWrite(Relay_6, RELAY_OFF);
  digitalWrite(Relay_7, RELAY_OFF);
  digitalWrite(Relay_8, RELAY_OFF); 
 
//---( THEN set pins as outputs )---- 
  pinMode(Relay_1, OUTPUT);   
  pinMode(Relay_2, OUTPUT); 
  pinMode(Relay_3, OUTPUT); 
  pinMode(Relay_4, OUTPUT);
  pinMode(Relay_5, OUTPUT);   
  pinMode(Relay_6, OUTPUT); 
  pinMode(Relay_7, OUTPUT); 
  pinMode(Relay_8, OUTPUT);
  pinMode(Reset, OUTPUT);
 
  delay(4000); //Check that all relays are inactive at Reset

//-----RECIEVER
     vw_set_ptt_inverted(true); // Required for DR3100
     vw_set_rx_pin(12);
     vw_setup(4000);  // Bits per sec
     pinMode(13, OUTPUT);
     digitalWrite(13,0);
     vw_rx_start();
     Serial.begin(9600);     // Start the receiver PLL running
 }
     void loop()
 {
     uint8_t buf[VW_MAX_MESSAGE_LEN];
     uint8_t buflen = VW_MAX_MESSAGE_LEN;

     if (vw_get_message(buf, &buflen)) // Non-blocking
     {
       if(buf[0]=='A'){
        Serial.print(buf[0]);
        digitalWrite(13,1);
        vw_wait_rx();
          if(buf[0]=='1'){
            digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_1, RELAY_OFF);
          }
          if(buf[0]=='2'){
            digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_2, RELAY_OFF);
          }
          if(buf[0]=='3'){
            digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_3, RELAY_OFF);
          }
          if(buf[0]=='4'){
            digitalWrite(Relay_4, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_4, RELAY_OFF);
          }
          if(buf[0]=='5'){
            digitalWrite(Relay_5, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_5, RELAY_OFF);
          }
          if(buf[0]=='6'){
            digitalWrite(Relay_6, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_6, RELAY_OFF);
          }
          if(buf[0]=='7'){
            digitalWrite(Relay_7, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_7, RELAY_OFF);
          }
          if(buf[0]=='8'){
            digitalWrite(Relay_8, RELAY_ON);// set the Relay ON
            delay(500);
            digitalWrite(Relay_8, RELAY_OFF);
          }
          digitalWrite(13,0);
       } 

 }
 }


I plan in the future on having several receivers.  So I want to have A be the receiver I am talking to then enter the number of the relay on that receiver.
6  Using Arduino / Networking, Protocols, and Devices / Re: Sending keypad entries over 433mhz transmitter on: June 01, 2014, 02:50:42 pm
+1 to what John said.

Depending on how the library function vw_send was written, it may be necessary to keep the cast, as well as adding the "&".

Code:
vw_send((uint8_t *)&key, 1);

But try John's way first - I might be wrong on this smiley




No errors when I use yours Hackscribble.  Will this send the whole message or just one character?  My trasnmitters/Recievers come in the mail tomorrow or I'd test it out myself.  Just wanted to get a head start on the coding before it arrives.
7  Using Arduino / Networking, Protocols, and Devices / Re: Sending keypad entries over 433mhz transmitter on: June 01, 2014, 02:45:39 pm
strlen() needs a character pointer but all you have is a single character.  You should probably use the value 1 instead.

You should probably not cast a character (8-bit value) as a character pointer.  Instead, use the 'address of' operator (&) to get the pointer to the character.

You can't use that pointer with strlen() because you have not put a null character in your character string to indicate the end.

Code:
   char key = keypad.getKey();
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send(&key, 1);
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);

That gets me a new set or errors:  Also would doing it that way allow me to send multiple characters at once or just one at a time?   I want the codes to trigger an 8 channel relay one the distant end.  If I enter A1* I wanted the RX to trigger relay one.   A2* for relay two and so on.

Code:
TransmitterA_002.ino: In function 'void loop()':
TransmitterA_002:54: error: invalid conversion from 'char*' to 'uint8_t*'
TransmitterA_002:54: error: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'
8  Using Arduino / Networking, Protocols, and Devices / Sending keypad entries over 433mhz transmitter on: June 01, 2014, 02:26:04 pm
I'd like to send my 4x4 keypad entries over a 433mhz transmitter.  I pretty new to arduino and not sure how to get the keypad char transmitted.  I get  a char conversion error.  The transmissions will be 3 digits  (example:  A1*,A2*,B2* etc.)

I know this is probably simple to do just not sure how to do it. 

Thank you for any help.

Code:

void loop(){
 
  char key = keypad.getKey();

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)key, strlen(key));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(200);
}

Code:
TransmitterA_002.ino: In function 'void loop()':
TransmitterA_002:55: error: invalid conversion from 'char' to 'const char*'
TransmitterA_002:55: error: initializing argument 1 of 'size_t strlen(const char*)'
9  Using Arduino / Sensors / IRremote breaking loop on: September 12, 2013, 09:59:56 pm
I want an infinite loop to start when I hit a button on the IR remote then stop when I hit another.

Code:
case 0xFF629D:
  for(int i = 0; i < 5;)
{
  setColor(255, 0, 0);  // red
  delay(100);
  setColor(0, 0, 255);  // blue
  delay(100);
}  
    Serial.println(" CH             ");
    break;

I understand I should probably be using a While loop, but I was unsure how to go about it.  Thanks for any help.
10  Using Arduino / Programming Questions / Compiling error with IRremote on: January 19, 2013, 10:21:30 am
Getting the following compiling error when trying to run IRtest from the example library.

Any help would be greatly appreciated.

ArduinoIRremotemaster\IRremote.cpp.o: In function `MATCH(int, int)':
/IRremoteInt.h:176: multiple definition of `MATCH(int, int)'
IRtest.cpp.o:C:\Users\Phil\Documents\Arduino\libraries\ArduinoIRremotemaster/IRremoteInt.h:176: first defined here
ArduinoIRremotemaster\IRremote.cpp.o: In function `MATCH_MARK(int, int)':
/IRremoteInt.h:177: multiple definition of `MATCH_MARK(int, int)'
IRtest.cpp.o:C:\Users\Phil\Documents\Arduino\libraries\ArduinoIRremotemaster/IRremoteInt.h:177: first defined here
ArduinoIRremotemaster\IRremote.cpp.o: In function `MATCH_SPACE(int, int)':
/IRremoteInt.h:178: multiple definition of `MATCH_SPACE(int, int)'
IRtest.cpp.o:C:\Users\Phil\Documents\Arduino\libraries\ArduinoIRremotemaster/IRremoteInt.h:178: first defined here


IRtest code:

/*
 * IRremote: IRtest unittest
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 *
 * Note: to run these tests, edit IRremote/IRremote.h to add "#define TEST"
 * You must then recompile the library by removing IRremote.o and restarting
 * the arduino IDE.
 */

#include <IRremote.h>
#include <IRremoteInt.h>

// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
//  decode_results *results = (decode_results *)v
void dump(decode_results *results) {
  int count = results->rawlen;
  if (results->decode_type == UNKNOWN) {
    Serial.println("Could not decode message");
  }
  else {
    if (results->decode_type == NEC) {
      Serial.print("Decoded NEC: ");
    }
    else if (results->decode_type == SONY) {
      Serial.print("Decoded SONY: ");
    }
    else if (results->decode_type == RC5) {
      Serial.print("Decoded RC5: ");
    }
    else if (results->decode_type == RC6) {
      Serial.print("Decoded RC6: ");
    }
    Serial.print(results->value, HEX);
    Serial.print(" (");
    Serial.print(results->bits, DEC);
    Serial.println(" bits)");
  }
  Serial.print("Raw (");
  Serial.print(count, DEC);
  Serial.print("): ");

  for (int i = 0; i < count; i++) {
    if ((i % 2) == 1) {
      Serial.print(results->rawbuf*USECPERTICK, DEC);
    }
    else {
      Serial.print(-(int)results->rawbuf*USECPERTICK, DEC);
    }
    Serial.print(" ");
  }
  Serial.println("");
}

IRrecv irrecv(0);
decode_results results;

class IRsendDummy :
public IRsend
{
public:
  // For testing, just log the marks/spaces
#define SENDLOG_LEN 128
  int sendlog[SENDLOG_LEN];
  int sendlogcnt;
  IRsendDummy() :
  IRsend() {
  }
  void reset() {
    sendlogcnt = 0;
  }
  void mark(int time) {
    sendlog[sendlogcnt] = time;
    if (sendlogcnt < SENDLOG_LEN) sendlogcnt++;
  }
  void space(int time) {
    sendlog[sendlogcnt] = -time;
    if (sendlogcnt < SENDLOG_LEN) sendlogcnt++;
  }
  // Copies the dummy buf into the interrupt buf
  void useDummyBuf() {
    int last = SPACE;
    irparams.rcvstate = STATE_STOP;
    irparams.rawlen = 1; // Skip the gap
    for (int i = 0 ; i < sendlogcnt; i++) {
      if (sendlog < 0) {
        if (last == MARK) {
          // New space
          irparams.rawbuf[irparams.rawlen++] = (-sendlog - MARK_EXCESS) / USECPERTICK;
          last = SPACE;
        }
        else {
          // More space
          irparams.rawbuf[irparams.rawlen - 1] += -sendlog / USECPERTICK;
        }
      }
      else if (sendlog > 0) {
        if (last == SPACE) {
          // New mark
          irparams.rawbuf[irparams.rawlen++] = (sendlog + MARK_EXCESS) / USECPERTICK;
          last = MARK;
        }
        else {
          // More mark
          irparams.rawbuf[irparams.rawlen - 1] += sendlog / USECPERTICK;
        }
      }
    }
    if (irparams.rawlen % 2) {
      irparams.rawlen--; // Remove trailing space
    }
  }
};

IRsendDummy irsenddummy;

void verify(unsigned long val, int bits, int type) {
  irsenddummy.useDummyBuf();
  irrecv.decode(&results);
  Serial.print("Testing ");
  Serial.print(val, HEX);
  if (results.value == val && results.bits == bits && results.decode_type == type) {
    Serial.println(": OK");
  }
  else {
    Serial.println(": Error");
    dump(&results);
  }


void testNEC(unsigned long val, int bits) {
  irsenddummy.reset();
  irsenddummy.sendNEC(val, bits);
  verify(val, bits, NEC);
}
void testSony(unsigned long val, int bits) {
  irsenddummy.reset();
  irsenddummy.sendSony(val, bits);
  verify(val, bits, SONY);
}
void testRC5(unsigned long val, int bits) {
  irsenddummy.reset();
  irsenddummy.sendRC5(val, bits);
  verify(val, bits, RC5);
}
void testRC6(unsigned long val, int bits) {
  irsenddummy.reset();
  irsenddummy.sendRC6(val, bits);
  verify(val, bits, RC6);
}

void test() {
  Serial.println("NEC tests");
  testNEC(0x00000000, 32);
  testNEC(0xffffffff, 32);
  testNEC(0xaaaaaaaa, 32);
  testNEC(0x55555555, 32);
  testNEC(0x12345678, 32);
  Serial.println("Sony tests");
  testSony(0xfff, 12);
  testSony(0x000, 12);
  testSony(0xaaa, 12);
  testSony(0x555, 12);
  testSony(0x123, 12);
  Serial.println("RC5 tests");
  testRC5(0xfff, 12);
  testRC5(0x000, 12);
  testRC5(0xaaa, 12);
  testRC5(0x555, 12);
  testRC5(0x123, 12);
  Serial.println("RC6 tests");
  testRC6(0xfffff, 20);
  testRC6(0x00000, 20);
  testRC6(0xaaaaa, 20);
  testRC6(0x55555, 20);
  testRC6(0x12345, 20);
}

void setup()
{
  Serial.begin(9600);
  test();
}

void loop() {
}
11  Using Arduino / Interfacing w/ Software on the Computer / Re: Printing temperature probe data in Processing on: January 13, 2013, 09:00:52 pm
Understood

I was planning on using commas for delimiting between temperatures.

I understand they are headers and titles.  How to create text for the data was my main question.

Ok I have the first temperature working with serialEvent().  Getting there.
12  Using Arduino / Interfacing w/ Software on the Computer / Printing temperature probe data in Processing on: January 13, 2013, 06:01:56 pm

I want to create a GUI using processing to display 3 temperature probes I have connected to my  Arduino.

 

I am able to get Processing to read the data. I have not seen anything about how to display this data in a window with text.

 

Any help I can get would be greatly appreciated.  I am a very new to this program.

 

Example of the serial data processing is getting from the println.  3 printsof it.

 

70.25
70.25
70.25
70.2570
.2570.25
70.25
70.25
70.25


 

Thanks

 

Phil

 

Processing code:

 

// Example by Tom Igoe

import processing.serial.*;

PFont f;

Serial myPort;  // The serial port

void setup() {
  // List all the available serial ports:
  size(480, 480);
  println(Serial.list());
  // Open the port you are using at the rate you want:
  myPort = new Serial(this, Serial.list()[1], 9600);
  f = createFont("Arial",16,true);
}

void draw() {
 
  background(255);
  textFont(f,16);                 
  fill(0);
  text("TEMPERATURES:",10,50); 
  text("Temp 1:",10,100);
  text("Temp 2:",10,150); 
  text("Temp 3:",10,200);

 
  while (myPort.available() > 0) {
    String inBuffer = myPort.readString();   
    if (inBuffer != null) {
      println(inBuffer);
     

    }
  }
}



 

Arduino Code:

 

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.


DeviceAddress T1 = { 0x28, 0x0E, 0xFF, 0xE9, 0x03, 0x00, 0x00, 0xFA };
DeviceAddress T2 = { 0x28, 0x0E, 0xFF, 0xE9, 0x03, 0x00, 0x00, 0xFA  };
DeviceAddress T3 = { 0x28, 0x0E, 0xFF, 0xE9, 0x03, 0x00, 0x00, 0xFA  };

 

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(T1, 10);
  sensors.setResolution(T2, 10);
  sensors.setResolution(T3, 10);
}

 

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print(" Error");
  } else {
    Serial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

 

void loop(void)
{
  delay(2000);
  sensors.requestTemperatures();
 

  printTemperature(T1);

  printTemperature(T2);

  printTemperature(T3);
}

 

 

 
1

13  Using Arduino / Sensors / Re: Converting DS18B20 output to integer value on: January 08, 2013, 01:04:00 pm
I'm having no problem getting the Thermometor to work.  Its getting it to work with the guino gui that is giving me fits.  Tells me its not an INT and gets an error.
14  Using Arduino / Sensors / Converting DS18B20 output to integer value on: January 07, 2013, 10:17:20 pm
Was wondering how to convert the DS18B20 output to integer value.  For use with the Guino graphvalue.
15  Using Arduino / Programming Questions / Re: OneWire error message on: January 07, 2013, 03:52:00 pm
Thank you

I knew it was simple.  I put the library in the right spot and it works now.

Pages: [1] 2