Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

new to Ardunio but trying to compile

Status
Not open for further replies.
I can't believe his book doesn't come with a CD of the examples or with a web address for downloading them. Typing in a page of text for each example is a huge waste of time and an exercise in frustration.


MrDEB's "programming style" has left him with almost no troubleshooting skills. He has always posted code for others to fix, resisted understanding why things don't work, and just when you see a glimmer of hope, he dumps the original code in favor of a different example he has found. This is from somebody who has driven himself crazy over the years.
 
Morning Jon

I can't believe his book doesn't come with a CD of the examples or with a web address for downloading them.

I had a good look at the book last night thinking I might get a copy as my Arduino skills are not much. It's out of print and very expensive unless you buy a copy in the USA which then makes shipping expensive. Sadly, there is a complete lack of either an example CD or a download point that I could find.

He has always posted code for others to fix, resisted understanding why things don't work, and just when you see a glimmer of hope, he dumps the original code in favour of a different example he has found.

I have to say I don't think that's quite fair.
The IRremote sketch which I corrected for him had something around 30 or so simple errors, case sensitives, mispelled, too many curly braces etc;
I think he has moved on from that because he said he needed to add a SWITCH .. Case element and that was later in the book, which is quite true.

I think the sketch posted last night is from the next chapter and something more complex but it is worth noting that, although I again corrected it for him, that was achieved by making only 3 alterations; the Serial.println error that you know about , a bracket missing off the end of a statement and one too many curly braces at the end of the sketch - which is something I do myself with alarming regularity !

This is from somebody who has driven himself crazy over the years.

I too continue driving myself nuts trying to write working code on a daily basis .. .. .

Changing the subject for a moment, Thank you for the content of your thread ' Jon's Imaginarium ' .. .. .. .. absolutely marvellous !!

MM
 
I have that book and the CD that goes with it.

Unfortunately, the book in question is called 'Programming Arduino in 24 Hours' by Richard Blum .. .. .:)

MM
 
curious how did you find the errors? I downloaded NOTEPAD++ but got lost.
the book that Ian posted looks similar but a different edition.
I get confused with the type set used.
Will print out corrected and make corrections
Thanks
 
Finding the /stray xxx error was a special case. When you copy and pasted, you picked up a non-prining character (one that doesn't normally show up). Forget about that for now.

In general, the IDE will try and show you what it doesn't like. Here are a few examples.

Error 1.jpg


Notice that the IDE highlights the line it doesn't like. LED_BUILTIN is a defined keyword, so it usually shows up in light blue, Notice on the highlighted line, it shows up in white. The means the IDE doesn't know this is a defined word. Look at other places it shows up. What's different in the highlighted line?




error 2.jpg


Again, look at the highlighted like and what the error says. The IDE is expecting a curly bracket. In this case, the error is a missing bracket in the next line, and the highlighted line is the last good line before things failed.



error 3.jpg


Highlighted line. "digitalrite" is shown in white instead of red like the the other places it's used. Why?



error 4.jpg


Highlighted line. "digitalwrite' shown in white instead of red like the other places it's used. Why?



In Arduino code, spelling counts (just like every other programming language). What counts way more here than in Swordfish is capitalization of certain letters. digitalwrite IS NOT the same as digitalWrite. There is NO FLEXIBILTY in this.

As I posted last night, two things will help:

* Use a dark theme like shown here to make the color coding more visible.

* Turn on line numbers (I explained how last night) to help keep track of where you are.
 
MrDEB, please put in at least as much effort understanding the above as I spent writing it. There really isn't any reason why this should need to be explained.
 
I read all your explanations and still need to go to black screen.
What I am really confused is the code I posted in #54 the PRINTIN statement. I kept coming up with an error but it was spelled correctly? I copy n pasted from another code the same statement THEN the printin turned red finally.
I ran that code but it dosen't exactly do what I want = output a value from 0 to 20.
I found this code and after I make some changes it should do what I want hopefully. Display the value on an 8x 8 matrix with an extra led to indicate over 10. This compiled just fine. now to do some surgery and slow the serial monitor down.
Code:
int soundPin = A0;
int LED1 = 2;
int LED2 = 3;
int LED3 = 4;
int LED4 = 5;
int LED5 = 6;
int LED6 = 7;
int LED7 = 8;
int LED8 = 9;

void setup()
{
Serial.begin(9600);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED7, OUTPUT);
pinMode(LED8, OUTPUT);
}

void loop()
{
long sum = 0;
for(int i=0; i<100; i++) // taking 100 sample of sound
{
sum += analogRead(soundPin);
}

sum = sum/100; // average the sample of sound

if (sum>=100) digitalWrite(LED1, HIGH); else digitalWrite(LED1, LOW);
if (sum>=200) digitalWrite(LED2, HIGH); else digitalWrite(LED2, LOW);
if (sum>=300) digitalWrite(LED3, HIGH); else digitalWrite(LED3, LOW);
if (sum>=350) digitalWrite(LED4, HIGH); else digitalWrite(LED4, LOW);
if (sum>=400) digitalWrite(LED5, HIGH); else digitalWrite(LED5, LOW);
if (sum>=450) digitalWrite(LED6, HIGH); else digitalWrite(LED6, LOW);
if (sum>=500) digitalWrite(LED7, HIGH); else digitalWrite(LED7, LOW);
if (sum>=550) digitalWrite(LED8, HIGH); else digitalWrite(LED8, LOW);
delay(10);
Serial.println(sum);
}
 
Alright where is the black screen option selected?
I looked at file preferences etc.
 
What I am really confused is the code I posted in #54 the PRINTIN statement. I kept coming up with an error but it was spelled correctly? I copy n pasted from another code the same statement THEN the printin turned red finally.

Geez oh grief!!!!!!!!!

Come on. Really????

I explained as well as anyone possibly could that the command is short for p r i n t l I n e where it is made up of the underlined characters in post #57.

P
R
I
N
T
L (ell, not eye!)
N

Try, try to understand what the commands mean and why they are spelled the way they are. Why would the command to print and terminate a line be called PRINTIN? That makes zero sense, right

Please consider my posts interactive. They require an acknowledgement and that questions be answered.
 
Last edited:
Jon.. Its all well and good shouting at him... The dark theme link you posted does not work.. Quick search

Dark Theme for Arduino IDE - Arduino Project Hub You can create a theme here MrDEB.. Once its in your arduino directory you select it in preferences..

Please check your link Jon...
 
Jon.. Its all well and good shouting at him... The dark theme link you posted does not work..

So sorry. The one time I didn't proofread (people here should try it some time), the link was messed up. It's been corrected.

Do you really think it wise to suggest creating a theme from scratch? How many pages of questions will result? The Dracula theme and others are pre-built and only require renaming a folder and copying a new one in its place.
 
I find a dark theme makes it a lot easier to see the color coding. I searched on "Arduino dark themes" and came up with a list of several that showed what each looked like. Dracula looked the cleanest to me; I'm not entirely sure why they named it that.... I haven't seen any dripping fangs. I downloaded it and followed the simple directions to install it. I don't know if others are installed differently.
 
I ran that code but it dosen't exactly do what I want = output a value from 0 to 20.
I found this code and after I make some changes it should do what I want hopefully. Display the value on an 8x 8 matrix with an extra led to indicate over 10. This compiled just fine. now to do some surgery and slow the serial monitor down.

Despite repeatedly asking, you have never stated what your end goal is here, so we are left to guess....

It sounds like you want to display a digit on a 8×8 LED matrix, which is the first time this has come up. Is this your goal?

If so, the code you posted isn't going to help at all. It's designed to light up 8 single LEDs in response to an analog level.

As has been discussed before in your other projects, if you want to display characters on an 8×8 matrix, you must multiplex the display. Using a different programming language doesn't change the technique you must use.

If displaying 1 – 10 is your goal, using two 7-segmenr LED displays would probably be easier and provide a more legible display. Practically, this would still require multiplexing, but it could be done with 2 individual digits and 12 i/o lines directly controlling the segments. (Multiplexing a 8×8 matrix requires 16 i/o lines or some hardware help, so maybe directly controlling the segments of 2 individual 7-segment displays might make the most sense).
 
yes I never though about using a 7 segment display but plan to after running across a project that used them for a VU meter, which is basically what I am looking for.
 
lets let the cat out of the bag
want to control the volume on the tv to a set desired level.
using the remote, train the Arduino using the remote, (volume up/down) then the user sets their desired volum level and the seven segment displays the level from 0-9 or 0 - ?
if a loud commercial comes on, the Arduino detects a louder than preset level then lowers the volume. If the pre set volume level is to low then the Arduino raises the volume (volume up) up to the pre set level.
The Arduino communicates via Infra red, same as using the tv remote by itself.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top