Go Down

Topic: More c# & VB.net source code, together with scetch (Read 9 times) previous topic - next topic

Riaan Deyzel

Good day

Exactly like this http://blog.renatopeterman.com.br/?p=164#comment-8, but in english, and with tilt support, current version only pans left to right, and i need up & down as well.
and pins 9 for pan & 10 for tilt and not the current pin 8.

Please see what you guys can do for me.


Riaan Deyzel

Sep 28, 2010, 10:18 am Last Edit: Sep 28, 2010, 10:29 am by riaan.deyzel Reason: 1
Here is the current scetch which I modified to change the pan servo to pin 9

Code: [Select]
// Importa a biblioteca Servo.h do arduino
#include <Servo.h>

// Cria uma variavel do tipo Servo que será
// o nosso servo.
Servo servo1;

// Array de char que receberá o comando
// via serial
char buffer[4];

// Variavel que identifica quantos
// caracteres foram recebidos, pois só é
// possível receber um caracter por vez
int received;

void setup(){

 // Define o baud rate (taxa de trasmissão) como 9600

 // Atribui o servo ao pino 9 do Arduino

 // Atribui o valor 0 para a variavel received
 received = 0;

 // Na posição 0 do array, atribui o valor '\0'
 // que identifica onde começa o array
 buffer[received] = '\0';

void loop(){

 // Verifica se existe alguma entrada de dados
 // disponivel na entrada serial

   // Salva os caracteres no array a cada iteração
   buffer[received++] = Serial.read();

   if(received >= (sizeof(buffer)-1)){

     // Imprime na saída serial o valor
     // Apenas para mostrar o valor

     // Converte o valor de "char" para "int"
     int numero = atoi(buffer);

     // Envia o comando para o Servo Motor

     // Zera novamente a variavel
     received = 0;

   // Limpa o buffer da entrada serial



That was the easy part, now I need to add support for an second servo "tilt servo" on pin 10, I can copy the code & buttons from the pan buttons and use them for the tilt buttons, but not sure how to link it to the scetch from the C# app, as the same servo on Pin 9 would probabbly move when I press the Tilt (up/Down Buttons). (http://www.renatopeterman.com.br/downloads/ProjetoArduinoServoControl.rar for  source code & http://blog.renatopeterman.com.br/?p=164 for original Scetch)
Can anyone please help with this?
Thanks  :-[


You may want to look into the Firmata project. It's more about remote controlling stuff attached to an Arduino from a PC.


Riaan Deyzel

I am an beginner with programming, more an electronics guy.
If anyone got time,and have an idea how to do this, please do this for me.
I have been strugling with this for 2 month.
I have wired everything up, Arduino to sensors, arduino to servo's, arduino to 15 A Pololu MotorDriver and then to 2X 12V drill motors, basically a fully completed robotic tank with CO2 Air rifle for an turret////but I can not control anything////.
[glow]I managed to control my motors via Firmata, then tried it with my servos, but they were very shakky,and I would like to push a button to move my servo's, and not move an sider to send PWM to arduino. A simple sketch just for these 5 buttons functioning will be appreciated.

Thanks for the repy. [/glow]

Previous quote of mine above.

Firmata only gives digital on/off buttons, nd no PWM buttons, instead they use sliders, which is not going to work well to contol an robotic tank.


Sorry about that, I missed it. I though there are also servo controls available for Fimata. I must have missed that.


Go Up