Loading...
Welcome,
Guest
. Please
login
or
register
.
May 24, 2013, 06:12:59 am
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: break
« previous topic
next topic »
Pages: [
1
]
Go Down
Print
Author
Topic: break (Read 140 times)
0 Members and 1 Guest are viewing this topic.
aceton
Offline
Newbie
Karma: 0
Posts: 3
break
«
on:
November 27, 2012, 06:30:55 am »
Bigger
Smaller
Reset
part of code
Quote
void
rec_tab(){
byte
i=0,chk=0,j=0;
while
(1){
if
(
Serial
.
available
()>0){
in_buff[j] =
Serial
.
read
();
chk^=in_buff[j];
j++;
if
(j==in_buff[1]+2)
break
;
lcd.
setCursor
(0,1);
lcd.
print
(chk,
HEX
);
}
}
lcd.
setCursor
(0,0);
lcd.
print
(
" after break "
);
lcd.
print
(chk,
HEX
);
}
Why break clear chk ??
Before break LCD display 0xA3 after break 0x00 ??
Logged
PaulS
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35526
Seattle, WA USA
Re: break
«
Reply #1 on:
November 27, 2012, 06:37:04 am »
Bigger
Smaller
Reset
Have you tried posting down the street at snippets-r-us.com? Here, we get to see ALL of your code, posted using the code icon (with the #), not the quote icon.
Logged
MarkT
0
Offline
Tesla Member
Karma: 71
Posts: 6625
Arduino rocks
Re: break
«
Reply #2 on:
November 27, 2012, 07:19:30 am »
Bigger
Smaller
Reset
break isn't clearing chk, your code is changing it. break exits the innermost enclosing loop or switch statement with immediate effect.
Logged
KeithRB
Offline
Sr. Member
Karma: 7
Posts: 395
Re: break
«
Reply #3 on:
November 27, 2012, 11:40:57 am »
Bigger
Smaller
Reset
break does not break out of "ifs", only loops. Your break leaves the while loop.
Logged
Pages: [
1
]
Go Up
Print
« previous topic
next topic »
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: break
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...