Go Down

Topic: Using the int command (Read 517 times) previous topic - next topic

laurielwright

I just got my Arduino and made my first sketch which worked as it should. My directions were to us the int command in order to simplify making changes later. When I try this nothing happens, the int does not go orange as it should. I am new to programming so don't know what to do, Can someone help me.

DrAzzy

#1
Nov 22, 2015, 08:04 pm Last Edit: Nov 22, 2015, 08:04 pm by DrAzzy
You have not posted any of the context that might explain what you're doing or being asked to do. Without more information, it's not possible to help you.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Delta_G

int isn't a command.  It is a data type for declaring variables.  Can you show an example of what is giving you trouble?

PS, ignore the orange thing.  Its a red herring ( or is it an orange herring).  Lots of stuff doesn't turn orange.  All orange means is that someone listed that word in a keywords file.  Not everything gets put into those.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

UKHeliBob

Where and how did you use this int "command" ?

Please post your program and explain what you tried.

It sounds like you were maybe advised to declare an int variable with a name and value so that the value could be changed later and the change would be reflected throughout the program.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

laurielwright

I was following the example of Lesson 1 by Paul McWhorter and had my red LED on and off and able to control times etc, Next he said to use the INT in order to simplify making changes later.

When I do this I get an error message and the INT does not turn Orange as his did.

Error message:"expected unqualified id before numerical constant"

Does this help any

Delta_G

Does this help any
Not much.  Can you POST THE CODE that caused the error so we might be able to see what you did wrong.  Without that all we can do is throw out guesses and nobody here is going to waste their time doing that. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

nickgammon

I was following the example of Lesson 1 by Paul McWhorter and had my red LED on and off and able to control times etc, Next he said to use the INT in order to simplify making changes later.

When I do this I get an error message and the INT does not turn Orange as his did.

Error message:"expected unqualified id before numerical constant"

Does this help any
Post your code, buddy. We aren't mind readers.

Please use code tags.

Read this before posting a programming question

How to use this forum
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

DrAzzy

We don't know who the hell Paul McWhorter is, or what his first lesson says, so that doesn't help us one bit...
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Gadgetman9

LaurialWright is this the code you're talking about?  I believe this Paul is on Utube.

Delta_G is right, int is not a command but a declaration of type. While I don't agree with Paul's naming convention of LEDPin, the code does work.  I believe he tells you in the video to play with the example and see what you can make it do. Do that by typing his example into the Arduino program interface verbatim and see what it does. Then play with it after it's working by changing the waitTimeOn and waitTimeOff numbers.

Being new to programming is confusing at first.  I find C++(the language you're using) one of the harder languages to get used to. Don't get discouraged.

With reading, practice, experimenting (As Paul says in his video) and perserverance, you'll learn this over time.  Any programming language is massive, and it takes quite some time to learn, especially if you've never done any type of programming in the past.

There is tons of information on the Arduino site where you can get answers without even posting in the forums.  Start under the learning menu and look at the tutorials there.  There are also many examples that came down with the Arduino software available under the file menu. You can use them directly without having to type them from a Utube video.  There are also lots of comments to help you understand what each line is for
 
There also lots of C++ tutorials online.  I've found cplusplus.com very useful. If you check them out, start here: http://www.cplusplus.com/doc/tutorial/program_structure/.  A google search will reveal hundreds of the same kind of site.

Experiment, play and have fun.


Code: [Select]
int LEDPin=13;
int waitTimeOn=900;
int waitTimeOff=100;

void setup(){

  pinMode(LEDPin, OUTPUT);
}

Void loop(){

  digitalWrite(LEDPin, HIGH);
  delay(waitTimeOn);
  digitalWrite(LEDPin, LOW);
  delay(waitTimeOff);

}

Delta_G

You got a typo in the declaration of void loop.  void shouldn't be capitalized. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Gadgetman9

You got a typo in the declaration of void loop.  void shouldn't be capitalized. 
Delta_G is correct, sorry.  I typed it into a word document and it must have capitalized it.

Go Up