C :: Arduino Programming - Control Motion Of Servo Motor
Jul 16, 2013
I am working on a project that requires using an arduino microcontroller to control the motion of a servo motor. The arduino language is pretty much C.
The original code is of the form:
Code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
[Code] .....
But the problem is I don't want the motor's motion to behave linearly (constant increments of the pos variable). My desired motion is a sinusoidal like function. How to approach this?
I am quite new to programming, especially with microcontrollers. My guess is that instead of the pos+=1, I would need something like pos+=sin(argument). I am not sure what that argument should be.
I would like to make a program for final project, which can let me send any file to my computer at home, and i can access any files in my computer when i am not at home.sending and getting file will be with socket programming.
i would like to reach all folders in computer, not only the folder, where client program exist. how can i access other folders at remote computer by using my program?
my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore.
how to pass a string from vb6 into the gsm module ... i am posting vb6 code ... below code passes
check1.caption=11BNELE0455 to MSCOMM2.output...
Static col As Integer
col = 3 lbl: If excelws.Cells(10, col).Value = "" Then excelws.Cells(9, col).Value = Format(Now, "dd/mm/yyyy") If (check1.Value = 1) And (Timer1.Enabled = True) Then excelws.Cells(10, 1).Value = check1.Caption
[Code]...
now i want to access this string a=0455 from c-code of arduino..how can i access this.. below is c-code for arduino uno.what is wrong with it.it is giving me error:invalid conversion from 'int' to 'const char*'.
//decalaration part of my code
#include <SoftwareSerial.h> char inchar[80][5]; // Will hold the incoming character from the GSMshield SoftwareSerial SIM900(7, 8); String textForSMS;
I am trying to implement same thing as given in following images:
i m working on "Wireless surveillance system using zigbee".
But i want to add external PIR motion sensor and wireless zigbee module with Arduino.
The images are stored in SD card. but my goal is when the PIR detects any motion the image should be stored in memory card (Done in attached code)and then that image should be transferred through zigbee (Zigbee Tx is connected with Rx Pin0 and zigbee Rx is connected with Tx Pin1). PIR sensor output is connected with Pin7 of arduino.
So what are the additions/modifications do i require for transmitting image on Pin1 in following code.
I am using this code
Code: // This is a motion-detect camera sketch using the Adafruit VC0706 library. // On start, the Arduino will find the camera and SD card and turn // on motion detection. If motion is detected, the camera will // snap a photo, saving it to the SD card. #include <Adafruit_VC0706.h> #include <SD.h>
Okay so this is part of a small uni module around the arduino board. The task is to simulate traffic lights at a junction. At the moment my code below runs through the sequence with 2 seperate lights. When one set of lights turns RED , the other turns GREEN.In my main loop method I need to add a button for a crossing. I want to be able to check if the button is pressed at each of the delays but do not want to have to hold it down.I have thought about putting it at the top of the loop but then the program will only check if button is pressed in that point therefore the user will have to hold it down?
Code:
int green1 = 13 ; int amber1 = 12 ; int red1 = 11 ;
int green2 = 6 ; int amber2 = 7 ; int red2 = 8 ; }
I know how to create your basic programm that compiles as a CLI or exports and/or saves data to a .txt file... But how does one build a GUI?
I ask because I am currently working on a programm for my Arduino controlled robot, in which I want to have a virtual on screen controller next to a map of my bots path.
I am building a project with an Arduino Uno that involves using analogue IR sensors to detect fast motion. By placing one sensor on top of the other, I want to be able to attain a variable integer from the difference in time between the responses of the sensors.
Here is my code I have so far, it is essentially for detecting motion for 1 sensor and then converting it into a MIDI note depending on how far away the motion is detected. There is also a part which compares the value from the previous time so that only above a certain amount of movement will trigger the note. I also have a variable delay to be controlled by a potentiometer.
Here is the datasheet for the sensors I'm using.
#include <MIDI.h> MIDI_CREATE_DEFAULT_INSTANCE();
int currentvalA = 0; //current sensor A value int previousvalA = 0; //previous sensor A value int valA = 0; // value to store sensor const int valchangeA = 40; //motion change value int del = 0; //variable delay value
I have researched quite extensively, experimented, and still cannot seem to change the properties of a control on an active winform from a user control.
So I have a user control which populates each dynamically added tab page in a tab control.
I have a textbox in the user control which I would like to type in, capture the text_change event, and change the text of the label in the winform.
How do I bind a DATE column in a DataGridView Control to a DatePicker control (using C#)? I already have the DataGridView control bound to a database stored procedure which takes a DATE value as a parameter and selects joining table based on the results.
I am using SDL 2.0. But I don't know how to handle mouse input. Do you think you can explain of how to do that? Or give me a link that explains that really great?
I know how to handle a mouse button that presses down for a sec.
Code: if (event.type == SDL_MOUSEBUTTONDOWN){ if (event.button.button == SDL_BUTTON_LEFT){ // Do something . . . } }
But not how to handle the mouse input of what the mouse is hovering over and that.
Like in a start menu of a game. I want a button for example to appear blue when I hover over it and when I click on it. It should start the game for example.
I have created plane as floor and sphere as ball. I used physics equations to it and ball falls under gravity. Now i want to attach visual arrow to this ball which moves with it according to velocity direction. If ball bounces then direction of velocity is changed so does arrow.
I'm trying to program an arduino to generate a Trapezoidal Motion Profile to control a DC motor with a quadrature encoder.
Essentially, the user will input the desired Target Position, Max Velocity and Acceleration (decel = -accel) and the code will calculate the target position versus time which will then be compared with the actual position. The result will then be subject to a PID calculation
My initial assumption was that I could use basic Newtonian physics to determine position (i.e. PT = P0 + V0T + 1/2AT2, VT = V0 + AT). However, after reading through documentation for pre-existing motion controllers, I discovered that the prevalent method was to use a discrete time method, which is as follows:
VK = VK-1 + A (A = Acceleration) PK = PK-1 + VK-1 + A/2
I'm having a hard time understanding quite how this equation would generate the target position versus time. In the case of Velocity, it seems to just add the acceleration to the current velocity. But what about everything in between?
I'm currently working on a simulation of the motion of magnets on a rod. As part of it, there are arrays of the properties of the magnets:
long double *accelerations; // These will later be dynamically allocated depending on the number long double *velocities; // of magnets long double *positions;
However, when I go to compile this, the compiler gives me these error for the pointers:
error: two or more data types in declaration of 'accelerations' error: two or more data types in declaration of 'velocities' error: two or more data types in declaration of 'positions'
Apparently, the compiler isn't recognising long double* as a type and is instead reading is as the two types long and double*.
I have a form with a picturebox and some buttons to move the picturebox. I don't want the user to guide the picturebox out of the form even by dragging the form border picturebox moves just in the form border, and also there is a button to guide the picturebox to the start position (start choose by user). What can i do?
I currently have a project that requires me to build a leap motion Virtual Piano. I am using Windows Visual Studio 2013 and i plan to use C++ to code it.
I assume my first step is to create a virtual piano using C++.. Then, link it with leap motion interface.
Can i know which audio library suits my project and how can i go about doing it?
But now I'm trying to use this to point to a function inside a class so instead of do11, i want to be able to point to Basic.Do11. Somehow this doesnt work and I keep on getting this message:
error: argument of type 'void (Basic::)()' does not match 'void (*)()'
I am trying to test my client-server socket program wherein the client connects to the server,client sends a message, server receives it and echo back to the client.So far, in the program server receives the message from the client, prints it BUT when it tries to send the message back to the client it shows an error.
sendto(): Invalid argument.I am new to socket programming.
Code:
//Server #include<stdio.h> //printf #include<string.h> //memset #include<stdlib.h> //exit(0) #include<netinet/in.h> #include<sys/socket.h> #define BUFLEN 512 //Max length of buffer #define PORT 10003 //The port on which to listen for incoming data }
I try to ON and OFF the LED's via parallel port. I connect the cathode of LED's with pin number 18 that is ground and anode of each LED is connected through a 1K resistor to pin 2 to 8. I write the following programe
I'm supposed to make a program that can tell which date, out of any number of dates entered by the user, is the earliest date. However, this is based off another program that I did not do in the last chapter. Since it's a pretty simple program to use as the base for the more "generalized" one, I decided to make the more basic one that can only take two dates, first. If it was just one integer, I could just use date1 for the first date and date2 for the second date, but each date uses 6-8 separate numbers.
how do I tell it something like, "if(date1 < date2)", with date1 and date2 including their month, day, and year. I could do a separate integer name/tag (I forgot what they're called) for each number, but that sounds like doing a lot more adding and subtracting, and like it could easily get messy.Should I, or can I, add all the numbers under the "date" together to see which date has the "lowest number" or "earliest date", or should I somehow handle each number, that is month, day, and year, separately?Here's the code so far:
Code:
include <stdio.h>int main(void) { int date1, date2; printf("Enter first date (mm/dd/yy): "); scanf("%d/%d/%d", &date1); printf("Enter second date (mm/dd/yy): }
I am trying to send a packet across a client/server communication. I am getting a seg fault (while running the program(It compiles fine)) when I try to read the neighbor file, You should be able to see this below the comment /***** Read neighbor file***/ :
I know this question must have been asked before, but the problem that I am facing is that I am using a library PoDoFo to parse PDF files. It seems that it is only compatible with C++.
Now I want the application to be web-based. That is, the user uploads a PDF file on the server, the server parses it and the parsed content is then sent back to the user.
Is such a thing possible with C++, or maybe any good work-arounds? Or should I look at server-side scripting languages like PHP and their respective libraries?
Where are the c programming variable name rules defined? I usually use these two websites for figuring out these kind of things but I don't see it anywhere.