element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum wireless display
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 14 replies
  • Answers 2 answers
  • Subscribers 393 subscribers
  • Views 870 views
  • Users 0 members are here
  • led
  • arduino
Related

wireless display

billpenner
billpenner over 11 years ago


I am attempting to build a keypad decoder, a wireless transmitter, a receiver and a 3inch LED display.

The decoder is working but I am having trouble determining what type data to transmit ie. character, byte or integer.

Since I will have to decode the data at the receiver, what would be the best type to use?

The initial code is;

 

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};

byte rowPins[ROWS] = { 9, 8, 7, 6 }; // keypad rows to Arduino pins

byte colPins[COLS] = { 12, 11, 10 }; //keypad columns to Arduino pins

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

#define ledpin 13 //define output pin to xmitter

void setup()
{
  
  pinMode(ledpin,OUTPUT);  //for testing
  digitalWrite(ledpin, HIGH); //for testing
  Serial.begin(9600);
}

void loop()
{
   //for (int(c); c <2; c++); I would like to accumulate three bytes and transmit together if possible
   char key = kpd.getKey();
  if(key)  // Check for a valid key.
  {
    switch (key)
    {
      case '#':     //Clear data for re-entry
        digitalWrite(ledpin, HIGH); // for testing
        break;                      // for testing
      case '*':     // Display data on receiver
        digitalWrite(ledpin, LOW);  // for testing
        break;                      // for testing
    
      default:    //send data to xmitter     not working! It only sends to! computer display. 
        Serial.println(key);      // for testing
       

     }
  }  
}

All help would be greatly appreciated. This is a project for our church.

Thanks

Bill

  • Sign in to reply
  • Cancel
  • shabaz
    0 shabaz over 11 years ago

    Hi Bill,

     

    Did the '#' and '*' do what they were intended to do (turn the LED on and off)?

    If so, then it's just the 'default' area of the switch statement that needs investigation.

    By the way, there should be a statement 'break;' after the Serial.println line (not sure if it compiles

    without that, but it's good practise to put it.

     

    Also, the println thing appears to accept any data type. When you have a single char, it is internally

    represented as a single byte, not as a string. So, as an example,  if you press the number 3, since your code represents it

    as '3', the compiler interprets that as an ASCII character which needs to be translated into a byte.

    ASCII char '3' is equivalent to the decimal number 51 (I just remember that ASCII char '0' is decimal 48

    and then you can add as appropriate, so 48+3=51).

    Another way to mentally remember it is that ASCII char '0' is hexadecimal 0x30. So, ASCII '3' would be

    hexadecimal 0x33.

     

    Anyway the point is, that according to this page it appears that if you use println with an integer (and I'm

    guessing it will have similar behaviour with a single byte which is what a 'char' data type is), then it will

    send to the serial port a "ASCII-encoded decimal". This means that if the byte is 51, then it will send four

    characters over the serial port: ASCII '5', ASCII '1' and ASCII CR and ASCII LF (carriage return and line feed).

     

    I don't know what your receive function looks like, but maybe you intend to send a single byte, in which case

    println can be replaced with 'write' as shown here.

    serial.write(key) will then send the single byte of value 51 using the same example.

    If you wanted to send the number 3 instead of the number 51, then you could do: serial.write(key-'0');

    which the compiler will translate to serial.write(key-48).

     

    I hope this helps. I don't know arduino, so I may be wrong on some points above.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago

    If you look at lesson 2 of my tutorials, it deals with reading a character at a time from the serial port into a buffer, a later lesson deals with doing the same from the Ethernet port. The serial port version can easily be adapted to read from the keyboard instead, it then goes on to deal with how to make decisions based on what is read

     

    you can find it here Fast Track to Arduino Programming

     

    the key part in this lesson in your case is replacing the serial.read() with your getkey() and also reducing the buffer size to 3 which you state is your requirements.

     

    You may want to start from lesson 0 though if your not familiar with programming the arduino

     

    If this is still to complicated right now, let me know and I can simplify the relevant parts of the program for you

     

    Regards

     

    peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • royston02
    0 royston02 over 11 years ago in reply to Robert Peter Oakes

    If you just want a wireless diplay, you can use a fpv kit

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to shabaz

    Thank you so much. I am digesting the replies and will report back to you my progress.

    Bill

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to Robert Peter Oakes

    Thank you Peter. I will indeed go through all your tutorials. I just checked one of them and there is great info in it. I will return with my progress. It seems I am making it much too complex. Thanks a bunch.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to royston02

    Thanks, but I only need to display a three digit number on a large LED. No video and no quad copters. Thanks tho. I now know what a FPV is.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • royston02
    0 royston02 over 11 years ago in reply to billpenner

    Then in that case, you can use an xbee/bluethoot module.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to Robert Peter Oakes

    Thank you very much. I am progressing very slowly but I am learning much in the process.

    I am sure I am making it far to complex, but as I say am learning much.

    It sounds simple to read a keyboard, display the 3 digit number  and send the number wirelessly to a receiver and display it there on a large LED display.

    Although I am proficient with hardware and electronic circuitry, I am inexperienced with programming.

    I have the keyboard decoding and reading. I have the local display working somewhat. I am working on the translation to drive the transmitter now.

    I am also  cleaning up some of my mistakes. I don't have enough time to devote to the project as I would like but I am enjoying it immensely.

    Thanks to all for your input and help.

    Bill

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • kidiccurus
    0 kidiccurus over 11 years ago in reply to billpenner

    Hang on, what wireless system are you using? did I I miss something. Also, if possible, just use wires. I know wireless is cool but it is a nightmare to get to work properly.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to billpenner

    As far as sending int's characters etc, you can define message format using a "structure" and using a "Union" to join multiple structures so you can choose what you send and when

     

    if the radio will only take char type then define a structure like that too and cast to it when you transmit

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube