Loading...
Welcome,
Guest
. Please
login
or
register
.
June 17, 2013, 11:55:09 pm
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: ERROR
« previous topic
next topic »
Pages: [
1
]
Go Down
Print
Author
Topic: ERROR (Read 144 times)
0 Members and 1 Guest are viewing this topic.
latee
Offline
Newbie
Karma: 0
Posts: 28
ERROR
«
on:
February 25, 2013, 06:28:37 pm »
Bigger
Smaller
Reset
I am not too knowledgeable about string...i want to recieve data,sending by the pc,and if the start of the data is d it will store to char num,????plz help me!!1
Code:
while (Serial1.available()>0){
d=Serial1.read();
if (d=='a'){String.toCharArray(num, 11);}
Logged
PaulS
Seattle, WA USA
Offline
Brattain Member
Karma: 332
Posts: 36396
Seattle, WA USA
Re: ERROR
«
Reply #1 on:
February 25, 2013, 06:34:14 pm »
Bigger
Smaller
Reset
What, exactly, are you trying to get into num? You've read ONE character from the serial port. You do not have a String instance. Even if you didn't, you haven't populated it with data from the serial port.
Logged
Nick Gammon
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 225
Posts: 14081
Lua rocks!
Re: ERROR
«
Reply #2 on:
February 25, 2013, 06:36:58 pm »
Bigger
Smaller
Reset
How to use this forum
* Post all your code please.
* Make a meaningful subject description (not just "ERROR").
* Don't use all caps in the subject.
* If you got an error, what is it?
Logged
http://www.gammon.com.au/electronics
pYro_65
North Queensland, Australia
Offline
Edison Member
Karma: 35
Posts: 1277
Re: ERROR
«
Reply #3 on:
February 25, 2013, 06:42:14 pm »
Bigger
Smaller
Reset
Did you see the posts in your last thread:
http://arduino.cc/forum/index.php/topic,150807.0.html
Quote
if the start of the data is d
there is only 1 character, and yes it is d but you check weather it is 'a'
String
.toCharArray(num, 11);
String is not a variable, this line is not valid.
Logged
latee
Offline
Newbie
Karma: 0
Posts: 28
Re:have a problem in interpreting data send by pc
«
Reply #4 on:
February 25, 2013, 07:06:08 pm »
Bigger
Smaller
Reset
i am wrong to my question...i am trying to store data from pc to arduino store it in a num...if the start is 'a ' the following number will be store to num...
Code:
while (Serial1.available()>0){
d=Serial1.read();
if (d=='a'){String.toCharArray(num, 11);}
Logged
pYro_65
North Queensland, Australia
Offline
Edison Member
Karma: 35
Posts: 1277
Re: ERROR
«
Reply #5 on:
February 25, 2013, 07:13:29 pm »
Bigger
Smaller
Reset
String.toCharArray(num, 11);
That is wrong, stop using it, delete it.
'd' has only read one character, which '
following number
' do you expect to store in num.
You are looping as long as there is data:
Code:
Serial1.available() > 0
But you do not do anything with it unless it is 'a'
and there is no end '}' on your loop.
Logged
latee
Offline
Newbie
Karma: 0
Posts: 28
Re: ERROR
«
Reply #6 on:
February 25, 2013, 07:42:36 pm »
Bigger
Smaller
Reset
wat must be my code????
Logged
Pages: [
1
]
Go Up
Print
« previous topic
next topic »
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: ERROR
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
-----------------------------
Using Arduino
-----------------------------
=> Installation & Troubleshooting
=> Project Guidance
=> Programming Questions
=> General Electronics
=> LEDs and Multiplexing
=> Displays
=> Audio
=> Motors, Mechanics, and Power
=> Sensors
=> Networking, Protocols, and Devices
=> Interfacing w/ Software on the Computer
-----------------------------
Topics
-----------------------------
=> E-Textiles and Craft
=> Robotics
=> Science and Measurement
=> Home Automation and Networked Objects
=> Device Hacking
=> Education and Teaching
=> Interactive Art
=> Product Design
-----------------------------
Development
-----------------------------
=> Suggestions for the Arduino Project
=> Other Hardware Development
=> Other Software Development
-----------------------------
Community
-----------------------------
=> Website and Forum
=> Products and Services
=> Gigs and Collaborations
=> Workshops and Events
=> Local Groups
=> Exhibition / Gallery
=> Bar Sport
-----------------------------
International
-----------------------------
=> Deutsch
=> Español
=> Français
=> Italiano
=> Portugues
=> Scandinavia
-----------------------------
Forum 2005-2010 (read only)
-----------------------------
===> Uno Punto Zero
===> Bar Sport
===> Frequently-Asked Questions
===> News
===> Exhibition
===> Workshops
===> Interfacing
===> Bugs & Suggestions
===> Development
===> Troubleshooting
===> Portugues
===> Deutsch
===> Español
===> Français
===> Italiano
===> Scandinavia
===> Development
===> Interfacing
===> Syntax & Programs
===> Bugs & Suggestions
===> Troubleshooting
===> Report Spam at Arduino.cc
===> Forum
===> Playground Wiki
=> General
=> Hardware
=> Software
=> International
=> Web/Forum/Email/Spam
-----------------------------
Using Arduino
-----------------------------
=> Storage
=> Microcontrollers
-----------------------------
International
-----------------------------
===> Humor y Debate
===> Talleres, Encuentros, ...
===> Tutoriels et cours
===> Réalisations et Projets Finis
===> Le bar
=> Nederlands
===> Software
===> Hardware
===> Proyectos
===> Documentación
=> India
===> Hardware
===> Software
===> Megatopic
-----------------------------
Products
-----------------------------
=> The Arduino Starter Kit
=> Arduino Due
-----------------------------
International
-----------------------------
===> Generale
-----------------------------
Products
-----------------------------
=> Arduino Esplora
=> Arduino GSM Shield
-----------------------------
Maker Faire Rome - The European Edition
-----------------------------
=> Makers
=> Events and Tour
Loading...