Go Down

Topic: What is Arduino exactly? (Read 1 time) previous topic - next topic

cjdelphi

Apr 04, 2012, 07:30 am Last Edit: Apr 04, 2012, 07:57 am by cjdelphi Reason: 1
I've seen C++ and C mixed together while coding in Arduino.

So is Arduino the IDE? and the language is C part C++

meanwhile check out my crappy weather station  I've just finished writing, i use a BOSH BMP085 sensor with Wiznet to deliver a basic weather station

http://110.175.97.110:1234

(South Australia, Adelaide, Clearview)
http://www.weatherzone.com.au/sa/adelaide/clearview   (official info to compare to)

So what am i coding in? hybrid C/C++ ?

skyjumper

C++ is a superset of C. The language of Arduino is C++.

Morris Dovey

Craig - It's working. Consider adding a location; weather info for 'noplace in particular' isn't very useful. :)

Unless you cause it to behave differently, the Arduino IDE compiles your code as C++.
There's always a better way!

cjdelphi

lol, the location is my bedroom, um South Australia (Adelaide) :P - but...

the question was, and you've answered it, C++ - i'll be honest i hate C++ as long as i get away with C (on the whole) looking code i'll be happy, my first program i wrote
was written in C when i was 8 (22 years ago) and i like C, not C++ i used Object Pascal (for objects) maybe i need to write a Pascal compiler lol..

anyway so it's C++ huh - thanks.

Nick Gammon

Somewhere in South Australia, I am guessing. Based on the 240V and the IP address.

Oh, and the temperature. It's 29C in Adelaide apparently, whereas it's a bit cooler where I am.

Look for the house with the bedroom light off.

(edit) ninja'd!  But I worked it out before he posted.
Please post technical questions on the forum, not by personal message. Thanks!

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

cjdelphi

lol, the bedroom light is a Cree 3 watt LED underdriven via a PNP 2222a transistor :)  and a 5v linear regulated supply :P

Yeah well, it is 3:39pm light will be off :)  lol - so can i say i code in C++ even though it looks identical to C? lol

Nick Gammon

You can say that if you want to.

A reasonably simple program in C++ will look the same as one in C. Well, put it this way, with some restrictions the same code will compile in C and C++.

But if you are doing this, for example:

Code: [Select]
Serial.println ("hello");


Then you are using C++.

Serial is an instance of the class HardwareSerial, and you are calling a member function of that instance.

And classes are a C++ thing. :) 

Sorry to disappoint you.
Please post technical questions on the forum, not by personal message. Thanks!

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

cjdelphi

awwww, yeah you're right Serial. <<object :(

grrrrr lol

westfw

Quote
can i say i code in C++ even though it looks identical to C?

I am capable of writing C programs in several languages.  C, C++, Java, Perl, ...  :-)

cjdelphi

#9
Apr 04, 2012, 09:16 am Last Edit: Apr 04, 2012, 09:19 am by cjdelphi Reason: 1
I've grown up on a diet of Pascal and Object Pascal, C++ (objects look scary) but C i can handle, PHP i can handle, C++ and objects that look like object::fsdfsdf scare me :P

Begin
 Writeln('Please no C++');
End.
lol

or

<?php
 echo "Please no C++ \n";
?>


or

printf(" Really no!");

lol, it's not that i don't like C++ just that i've been spoilt with objectpascal

EG.

Code: [Select]

Var
S: String;
Key,B: Byte;
N: Integer;
begin
S:=Edit1.Text;
Key:=55;
For N:=1 to Length(S) do
 Begin
   B:=Ord(S[N]);
   B:=B Xor Key;
   S[N]:=Chr(B);
 End;
 LoadLibrary
Edit1.Text:=S;



for (n=0; n<StrLen; n++)
{
 int b = 0;
 int key = 55;

//  B:=Ord(S[N]);  //ord is the Decicmal of Ascci value, eg, A = 65; so abcde becomes 65 66 67...
 //  B:=B Xor Key;  // xor 55 with 65 (A or whatever)
  // S[N]:=Chr(B);  //replace string back with the XOR'ed version

 
}

how would you do that in C/C++ ?  

The 'English' descriptions  Begin End; XOR, it's all pretty much explained to you as you code, where as with C++ you have to remember so very specific info - i'm spoilt lol

Nick Gammon

I know exactly what you mean. I spent 10+ years programming in Turbo Pascal. C seemed really strange at first. But, you adjust ...
Please post technical questions on the forum, not by personal message. Thanks!

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

skyjumper

If you can handle C as you say, then what makes C++ so scary? Its not as bad as you think. I don't think its bad at all.

CrossRoads

Almost seems like BASIC with semicolons & { }s at this point.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy