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 860 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
Parents
  • 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
  • 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
Reply
  • 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
Children
No Data
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