int sensorValue = analogRead(44000); //why does this function accept 44000 as the pin # when there is no such pin?
int digital = digitalRead(A0); //Why does digitalRead accept an analog pin variable (A0)
digitalWrite(0,34770); //why does digitalWrite accept a number and not the variable HIGH or LOW? //What does the number mean in this case?
analogWrite(8,100); //why is this accepted when pin 8 is not PWM capable?
Well my answer would be, the compiler and framework only takes you so far...and the Arduino framework wants to leave options openE.g. maybe there would someday be an arduino with more than 16 or 256 or 32768 digital pins
You can use an "analog pin" as a digital pin if you choose(As to digitalWrite( int, int) I am actually with you there I tend to think in terms of digitalWrite(int, bool))
But also,why can you park a sofa in your garage?why can your front door accept a motorcycle?why does your bank allow you to overdraft your account and then charges you a fee?etc etc
Yes, but you select your board in the IDE, hence I would think the compiler would know what pins are used for what
I mean if it can discriminate between high and HIGH it seems it would know that an analog variable would not apply to a digital pin.
I learn by "breaking things" so I wanted to see how the compiler behaved before I get my Arduino kit.
In strange and mysterious ways...
Right now it's a solution in need of a problem but I'm sure I can remedy that in due time.
QuoteRight now it's a solution in need of a problem but I'm sure I can remedy that in due time.Oh, so you ordered a Due? Or, should that be in Uno time?
I'm a model railroader and I plan on trying to use the Arduino on the layout in some fashion. Right now it's a solution in need of a problem but I'm sure I can remedy that in due time.
Should be fun! I was blown away by this model airport http://www.youtube.com/watch_popup?v=gn1qMYfFrro&feature=related
Some programming languages support the concept of constrained types and would prevent invalid values from being accepted by the compiler. The 'C'/C++ language doesn't do this. As long as the valoue you supply is of the correct type (or can be converted into the correct type automatically by the compiler) the compiler will accept it. If the compiler accepts it, then the effects of passing in invalid values depend on the run-time implementation of the functions being called. The Arduino run-time library seems quite robust and will probably try to do something sensible in most cases, but it will always be possible to write, compile and run code which is logically nonsense, but valid as far as the compiler and runtime implementation are concerned. Your job as a programmer is to avoid or eliminate those problems.
#if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial;#elif defined(USBCON) #include "USBAPI.h"// extern HardwareSerial Serial_; #endif#if defined(UBRR1H) extern HardwareSerial Serial1;#endif#if defined(UBRR2H) extern HardwareSerial Serial2;#endif#if defined(UBRR3H) extern HardwareSerial Serial3;#endif