First of all, im sorry about my bad english and the fact that i am actually a noob about Arduino stuff !
I have a kinda of doubt and i want some orientation..
I have a project, which its suppose to send codes to Arduino.. like, i have some code, something like this :
[...]
{
digitalWrite(ledpin, delay);
}
So, i would have a bar, to set a delay on the C# program, so.. it wil define a delay and send it to Arduino..
My point is.. is it possible to send like, print in the C# :
digitalWrite(ledpin,delay);
and this goes instantly to the arduino and become.. a 'code'?
Basicly, how can I make a C#/Python application to 'send codes' to my arduino, using buttons?
Sorry for my awfull english and very very thank you all !
I can't send program code to Arduino, because the code is compiled in Arduino compiler and to the board is upload in different stale like you write it.
But if you want send commands like "led_13_ON" to switch led on you can write simple string comparison and compare string from incoming serial data.
If i have three things :
A int to store the time it will be on ( delay )
A int to tell how much 'energy' to send ( an analog value )
Can i make a C# interface, that wil send a value to the arduino code, like, i connect the USB in the board and in the computer, and i send 145. Is there any1, using any component to make arduino 'store' this value? And, when its turned on w/o the serial cable, it still sending 145?
Basicaly i have an automation system that can get some 'extra-configurations' to any eletronic dive.. my doubt is, can i configure the Arduino functions and settings in the C#?
As you sayid i cant change the source program, bcz of the compiler. ( i have some hard dificculty to express myself in english ) Do you know how many thigns, and, what can i do? Like, configuring times, energys, and etc? Like sendint and storing constants? Basicly, how many things can i do interfacing C# and Arduino.;.
Can i send, LED_ON, compare it with a string, and make it stored?
Like, i do by C# " hey, turn LED_ON " and it turns the led on. But can i configure that by the C#, like " hey, always turn LED_ON" and then by, arduino always turn led on, even w/o the usb cable?
Its like.. sending a information to arduino, and store this info at her?
need to establish serial communication between c# and Arduino so to pass strings forth and back and then deside a way of comparing these strings to take actions ... find how to open, read, write and close Arduino's com port in C#
Indeed. Like dgar said, you need an communication interface, or better yet, a messaging library. It just so happens that I wrote such a library XD. That is to say, I've written a C# version of the Arduino CmdMessenger messaging library, that runs in .NET and Mono.
It comes with a set of examples on how to send & receive messages between the Arduino and your .Net application.
If all you want to do is control the brightness of an LED using the serial port, this code is good for you:
const int ledPin = 10; // the pin that the LED is attached to (Must be PWM ) (PWM has a ~ next to it)
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
analogWrite(ledPin, incomingByte * 128);
}
}
Open up the serial monitor from the Arduino IDE (Ctrl+Shift+M) and send a value from 1 to 8.
gabrielerzinger:
make arduino 'store' this value? ...
Can i send, LED_ON, compare it with a string, and make it stored?
Like, i do by C# " hey, turn LED_ON " and it turns the led on. But can i configure that by the C#, like " hey, always turn LED_ON" and then by, arduino always turn led on, even w/o the usb cable?
Its like.. sending a information to arduino, and store this info at her?