Can anyone please help me with the following project.
I need a c# or VB app that looks and works similar to this one that i created http://robotcontrol.yolasite.com/robotics-forum.php#bn-forum-1-1-4078249718/6874 but the one I created does not work, it was only used as a template and example.
I am currently using Firmata, bit the PWM sliders are just not cutting it.
Even if someone out there know how to convert the PWM sliders in Firmata to buttons I would realy appreciate it.
Even if someone out there know how to convert the PWM sliders in Firmata to buttons I would realy appreciate it.
You want to be able to push the button some amount in C#? Doesn't make sense. Buttons are either pressed, or not. Sliders have a range of values. You can't use a button in place of a slider.
I would like to click on momentary buttons, every click makes it move 10 degrees.
Exactly like this project, but only adding support for another servo (servo on pin D9 & D10) http://blog.renatopeterman.com.br/?p=164 and in english if possibe.
I do not have any programming knowlege, so would really appreciate it if anyone could send me the modified source, or a similar pan tilt project source someone might have done to pan and tilt two servos via arduino.
Please help with thIis, I have tried this now for about 6 months now.
I have managed to get a C++ app working, turning the led on pin 13 on and off.
Follow this link for example: Arduino Playground - CPPWindows, but i would now like to use the same button to make a servo move about 10 degrees every time i click the button.
Please give me some input on this, or links to similar C++ or C# apps.
Does that mean that I only need to change the scetch to perform the function, If so, anyone out the willing to try this please.I am reletavely new to the Programming world, and the link above is actualy the first app that I have ever written.
Does that mean that I only need to change the scetch to perform the function
Yes.
If so, anyone out the willing to try this please.
Aren't you? There are sample sketches to control a servo in a variety of ways. Look at them to understand how a servo is controlled. Then, change the source of the control data to the serial data that you receive.
Will the following code work to control a servo conected to Digital Pin9?
I am planning to copy the C++ Button & create another button, but just changing the value sent to '00'.
/*
* Serial Read Servo
* -----------------
* Moves a Servo connected to digital pin 9.
* The Servo will move the number given by a
* ASCII number read from the serial port.
* One Servo with two buttons (Pan Left & Pan Right)
* Created 10 March 2011
*/
int Servo1 = 9; // select the pin for Servo1
int val = 0; // variable to store the data from the serial port
void setup() {
pinMode(Servo1,OUTPUT); // declare Servo1 pin as output
Serial.begin(9600); // connect to the serial port
}
void loop () {
val = Serial.read(); // read the serial port
if (val > '0' && val <= '180' ) //Button1 Pan Left represented by a '0'
if (val > '00' && val <= '180' ) //Button2 Pan Right represented by a '00'
val = val - '0'; //Read Value from Button1
val = val - '00'; //Read Value from Button2
for(int i=0; i<val; i++) //Button1 Pan Left
for(int i=00; i<val; i++) //button2 Pan Right
Serial.println("MOVE!"); //message to display in Serial Monitor
digitalWrite(Servo1,val);
delay(15);
}
#pragma once
namespace ArduinoPinControl {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::IO::Ports::SerialPort^ serialPort1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::ComponentModel::IContainer^ components;
private:
/// <summary>
/// Required designer variable.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->serialPort1 = (gcnew System::IO::Ports::SerialPort(this->components));
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// serialPort1
//
this->serialPort1->PortName = L"COM17";
//
// button1
//
this->button1->Location = System::Drawing::Point(3, 37);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"Left";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(148, 37);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 1;
this->button2->Text = L"Right";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click_1);
//
// button3
//
this->button3->Location = System::Drawing::Point(85, 37);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(57, 23);
this->button3->TabIndex = 2;
this->button3->Text = L"Center";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(225, 99);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Arduino Control";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->serialPort1->PortName = "COM17"; // Replace with your COM port!
this->serialPort1->Open();
this->serialPort1->Write( "0" ); // In the future, you'll expand on this
// to write your custom data to the board
this->serialPort1->Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e) {
this->serialPort1->PortName = "COM17"; // Replace with your COM port!
this->serialPort1->Open();
this->serialPort1->Write( "00" ); // In the future, you'll expand on this
// to write your custom data to the board
this->serialPort1->Close();
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
this->serialPort1->PortName = "COM17"; // Replace with your COM port!
this->serialPort1->Open();
this->serialPort1->Write( "000" ); // In the future, you'll expand on this
// to write your custom data to the board
this->serialPort1->Close();
}
};
}
Thanks PaulS for your input so far, you do contribute very valueble information, and you definitely know alot about coding and hardware.
I realy do appreciate it.
Please note that I have now created 3 more buttuns for a second servo, but they are not coded in yet to do anything, so ignore buttons 4 through 6 in the C++ Code.
Revised Scetch:
/*
* Serial Read Servo
* -----------------
* Moves a Servo connected to digital pin 9.
* The Servo will move the number given by a
* ASCII number read from the serial port.
* One Servo with two buttons (Pan Left & Pan Right)
* Created 10 March 2011
*/
int Servo1 = 9; // select the pin for Servo1
int val = 0; // variable to store the data from the serial port
void setup() {
pinMode(Servo1,OUTPUT); // declare Servo1 pin as output
Serial.begin(9600); // connect to the serial port
}
void loop () {
val = Serial.read(); // read the serial port
if (val > '1' && val <= '180' ) //Button1 Pan Left represented by a '1'
if (val > '2' && val <= '180' ) //Button2 Pan Right represented by a '2'
if (val > '3' && val == '90' ) //Button3 Center represented by a '3'
val = val - '1'; //Read Value from Button1 converted from character to number
val = val - '2'; //Read Value from Button2 converted from character to number
val = val - '3'; //Read Value from Button3 converted from character to number
for(int i=1; i<val; i++) //Button1 Pan Left
for(int i=2; i<val; i++) //button2 Pan Right
for(int i=3; i<val; i++) //button3 Center
Serial.println("MOVE!"); //message to display in Serial Monitor
digitalWrite(Servo1,val); //Write Value to Servo1
delay(15); //Delay for Servo1
Serial.flush(); //Flush Serial Data, to prevent intermittent movement of servo
return;
}
Please note that I have now moved this Post to this link http://arduino.cc/forum/index.php/topic,54994.0.html, as I no longer use C# or VB to control a servo, I now use C++ in Windows, and got it working to an certain extent.