Thank you all,
Let me tell where I got lost after searching an answer for my question.
These were the steps that I was willing to do in Order.
STEP1:
The code that I am wishing to translate to c++ is as follows
int solenoid = 13;
// assuming the power transitor connected to the solenoid is controlled through digital pin 13
void setup()
{
pinMode(solenoid,OUTPUT);
//digital pin 13 is set to output
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
//the variable sensorvalue reads the analog data from pin A0
Serial.println(sensorValue);
if (sensorValue > 500)
{
//if the sensorValue is less than 300, the solenoid is opened for a period of 10s (temporarily, real model the value should change)
//then closed
digitalWrite(solenoid,HIGH);
delay(5000);
digitalWrite(solenoid,LOW);
}
delay(10000);
}
The translation I think should be pretty simple.
Lets say I compile the resulting code and get a .hex file.
STEP2:
I Upload ArduinoISP sketch to my arduino board.
STEP3:
Altering the board.txt
As explained in this page, I insert a custom board. But the page says to use an option "BOARD.upload.using=arduino:arduinoisp", but the page where these options are documented says that this option is no longer supported in arduino 1.0 , my arduino ide shows "arduino 1:1.0.5_dfsg2-2" which means that option is not supported in mine either ( I am not sure).
STEP4:
I connect my Arduino uno board and the ATMEGA328p on breadboard as shown here under "wiring" section.
STEP5:
At this point I assume I should choose the custom board that I previously inserted via board.txt under tools.
Under programmer should I choose "ARDUINO AS ISP"
STEP6:
Now if I want to burn bootloader I shall click "Burn bootloader" option under tools.
If I want to upload a arduino sketch (to my custom board) can I be using the standard upload button from the arduino IDE.
If I want to upload my .hex file how should I be proceeding (I guess avrdude should be used).
If all this went successful, I would have burned the bootloader/ my arduino sketch / .hex file but the custom board works with 16 Mhz.
If I want to lower my clock frequency ( I am thinking to use the in build 8 Mhz or lower clock frequency), what should I be doing??
To summarize:
- What is the alternative to BOARD.upload.using in arduino 1.0 ? (My wild guess is that the "Arduino as ISP" sketch or the choosing of "Arduino ISP" shall take care of that)
- How to set the clock frequency of the mcu of the custom board.?
I could not determine what the intent was, either
My intention of using c++ was that, c++ is more generic than arduino that's all. Of course using c++ comes the disadvantage of not able to use the diffrent arduino libraries.
This thread also has discussed things on very similar lines.
with regards
G.Gnanasenthil