Search the Community

Showing results for tags 'servo'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Found 17 results

  1. I have a code from an arduino to control servo position based on the distance output of the ultrasonic sensor. The servo just turns back and forth and there's no serial output at all. Everything is attached to the appropriate pins. I'm literally brand new at this so i really have no idea how to trouble shoot. Any help would be appreciated. This is the code i'm using. #include <Servo.h> //Setup the variables for the HC-SR04 const int trigPin = 3; const int echoPin = 4; // create servo object to control a servo // a maximum of eight servo objects can be created Servo myservo; // variable to store the servo position int pos = 0; void setup() { // initialize serial communication: Serial.begin(9600); // attaches the servo on pin 9 to the servo object myservo.attach(2); } void loop() { // establish variables for duration of the ping, // and the distance result in inches and centimeters: long duration, inches, cm; // The sensor is triggered by a HIGH pulse of 10 or // more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: pinMode(trigPin, OUTPUT); digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read the signal from the sensor: a HIGH pulse whose // duration is the time (in microseconds) from the sending // of the ping to the reception of its echo off of an object. pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); // convert the time into a distance inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); //Tell the Arduino to print the measurement in the serial console Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); // This if-else statement tells the Arduino at what distance // it should trigger the servo, what the servo should do, // and what it should do if the distance is too far away. if (inches <= 24) {sweep(3); } else if (inches >= 24) {myservo.write(pos); } // Tell the Arduino to wait 0.10 seconds before pinging the // Ultrasonic Sensor again. delay(100); } // Converts the microseconds reading to Inches long microsecondsToInches(long microseconds) { // According to Parallax's datasheet for the PING))), there are // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per // second). This gives the distance travelled by the ping, outbound // and return, so we divide by 2 to get the distance of the obstacle. // See: return microseconds / 74 / 2; } //Converts the Microseconds Reading to Centimeters long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; } //This sub-routein is what dictates the movement of the servo void sweep(int NUM_OF_CYCLES) { // Tells the Arduino to start this loop at 0 and incriment it by 1 // each time the loop completes. This is how the Arduino knows to // stop the loop when a specific number of the // Sweep routein has been ran. for (int j=0; j<NUM_OF_CYCLES; j++) // goes from 0 degrees to 180 degrees for(pos = 0; pos < 180; pos += 1) { // in steps of 1 degree // tell servo to go to position in variable 'pos' myservo.write(pos); // waits 15ms for the servo to reach the position delay(10); } // goes from 180 degrees to 0 degrees for(pos = 180; pos>=1; pos-=1) { // tell servo to go to position in variable 'pos' myservo.write(pos); // waits 15ms for the servo to reach the position delay(10); } }}
  2. Hi, I tried my hand for the first time on a servo and my experience may be helpful to other people. Servos are controlled by the length of a pulse. This pulse is repeated ca. every 20mS. The pulse length can vary coarsly between 1 and 2 mS. The pulse length determines the rotation angle. If the servo starts up, it goes to a middle position, corresponding to a ca. 1.5 mS pulse. For shorter pulses the servo turns in one direction, for longer pulses to the other. The range is limited, mostly to +/- 90 degree, the accurate values depend on the servo, as does the min/max widths. Mine had a range of a bit more than 180 degree for a min pulse width of 680 uS and a max width of 2.62 mS. However, you should not use these values but allow for some safety margin. Otherwise the motor may just not reach (e.g. due to slip or play) the position and the motor tries hard and gets hot. Most servos have 3 wires that are color coded from bright to dark, the color may change. The brightest is the signal pin where the pulses are fed. The middle one, mostly red, goes to Plus and the darkest one (brown, black..) goes to ground. Energia comes with a helpful server library. There an object: "Servo" is declared. You initiated the server by the method "attach". It comes in 2 varieties (assuming we declared an object "myservo"): myservo.attach(pinNo); myservo.attach(pinNo,minVal,maxVal); where pinNo means the launchpad pin number of the pin used to control the servo. min/maxVal are the minimal/maximal pulse width you want to use. This is not clearly described in the library and confused me bit. In further commands you can confortably deal with degrees beween 0 and 180. The library will transform the degree values into pulse widths, where 0 degree corresponds to the minimal pulse width and 180 degree to the max you specified. If you do not specify min/max values, some default values are used. In may case the lower default value could not be reached and the motor got hot. Therefore, it is better to determine correct values and specify these, using the second form of "attach". After initialization the servo goes to the 90 degree position. To send it to the 0 degree positio you would write: myservo.write(0); My servo did not respond quit linear. To send it to the 90 degree position I had to say 83 degree. Here is a small test program: // test for 9g Servo // 1. Button press -> 0 degree // 2. Button press -> 90 degree. Due due nonlinearity we need 83 degree // 3. Button press -> 180 degree. // 4. Button press -> 90 degree. #define sig P1_4 // signal for servo #define but P1_3 // button #define minWidth 770 // min pulse width in uSec of servo (680 allowed) #define maxWidth 2595 // max pulse width in uSec of servo (2620 allowed) #include <Servo.h> Servo myservo; void setup() { myservo.attach(sig,minWidth,maxWidth); pinMode(but, INPUT_PULLUP); } void loop() { while (digitalRead(but)); myservo.write(0); delay(500); while (digitalRead(but)); myservo.write(83);delay(500); while (digitalRead(but)); myservo.write(180);delay(500); while (digitalRead(but)); myservo.write(83); delay(500); } Note that due to nonlinearity of the servo I need to specify 83 degree for a 90 degree rotation. For test purposes you may power the servo directly from the launchpad (provided you do not have a monster servo with a hugh current consumption). In the enclosed picture I control the servo from launchpad pin P1_4 and power it directly from the launchpad. Have fun, Daniel
  3. Hi, Sorry for the repost, I save my preview topic in the wrong place I think (, if someone can delete this one...). I am using an MSP432P401R launchpad Rev B with Energia 17 on Windows 10. I've recently got this issue: I can't control servomotors with the Servo.h librairy and at the same time send several PWM. As soon as I called the "attach" function from Servo, the others call to analogWrite in my code don't work anymore. I think it is due to some timer conflicts (both functions using A0 timer ?), but I can't figured out how to fix the problem. I see something wierd in the Servo librairy code (in Servo.cpp:72): //timerParams.clockSource = Timer_Source_SMCLK; This instruction, that seems to choose the timer to use, is commented. Moreover I noticed that several defined are not used in the code of Servo (from Servo.h): #define SERVO_TIMER TIMERA0_BASE #define SERVO_TIME_CFG TIMER_CFG_B_PERIODIC | TIMER_CFG_SPLIT_PAIR #define SERVO_TIMER_TRIGGER TIMER_TIMB_TIMEOUT #define SERVO_TIMER_INTERRUPT INT_TIMERA0B #define SERVO_TIMER_AB TIMER_B #define SERVO_TIMER_PERIPH PRCM_TIMERA0 I have tried to modify "A0" by "A1" without success. Did someone run in a similare problem and could give me some clue to fix it ? Thanks Nathan
  4. I am using an MSP430fr5969. The board only has one hardware pwm available and it located on P1.2. For my application, I need to generate two different pwm signals to control two different motors. One of those is a servo, the other is a linear actuator but it is controlled through a motor speed controller that uses a pwm input (replicating that of an RC receiver). Can I use the servo library and attach a servo to any pin or does that pin have to have hardware pwm? I looked through the Servo.cpp file and it seems to be doing software serial. When i run servo examples, and hook the pin up to an oscilloscope I do not get nice square waves being generated as an output. Currently I am using pin 9, the defualt for the servo libraries. Thanks, Nolan
  5. Hi all, I am trying to control a common rc servo with launchpad. I am using timer for pwm signals. But my code doesn't work. I am stuck. Basic codes from ti tutorials don't work either. My servo is : SM-s3317s I power it with arduino uno (5V and GND) also connect the control wire to launchpad (p1.2) . I checked the servo with arduino, it doesnt have any problem. I tried to adjust pwm period to 20 ms and also tried to have high pulses between duration of 1ms-2ms as it is seen in the code. my mcu is : g2553 Here is my code : #include <msp430g2553.h> #define SERVO_BIT BIT2 #define SM_clk 1100000 #define servo_freq 50 int i; void init() { int PWM_period = SM_clk /servo_freq; P1DIR |= SERVO_BIT; //direction is set P1SEL |= SERVO_BIT;// port 1 function is set. TA0CCR0 = PWM_period-1; // pwm period TA0CCR1 = 0; //duty cycle = TA0CCR0/ TA0CCR1 TA0CCTL1 = OUTMOD_7; } int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer init(); TA0CTL=TASSEL_2+MC_1; // starting timer by setting clock source SMCLK of timer and UP mode while(1){ TA0CCR1 = 1100; __delay_cycles(1000000); TA0CCR1 = 1300; __delay_cycles(1000000); TA0CCR1 = 1500; __delay_cycles(1000000); TA0CCR1 = 1800; __delay_cycles(1000000); TA0CCR1 = 2200; __delay_cycles(1000000); } return 0; } Does anyone have any suggestions??Is there something i did wrong?? Thanks for your time and answers!! Erdem
  6. Hello everyone! We're a small group of science enthusiasts with varied interests who got together a little over a decade ago after seeing a video about the (then) world altitude record for Water Rockets. Everyone here surely remembers fondly the small plastic rockets that you filled with water and pumped with compressed air and can shoot up 50 feet or so? Well, there exists a small niche of rocketry enthusiasts who design and build their own high performance versions of these rockets that can fly hundreds or thousands of feet in the air. With their short but powerful boost phase, water rockets are ideal for lofting experiments and payloads that commonly available pyrotechnic rockets simply cannot budge. The primary benefit to these rockets is that they don't use combustion to fly and don't use pyrotechnics in their recovery systems, so they are not heavily regulated and are vastly less expensive to build and fly. Water Rocketry attracts a wide range of people with different backgrounds from all over the world. Given that water rockets are assembled from common everyday materials, the cost to get started is minimal, and this is very appealing to those of us who are on a budget. How this relates to the MSP430 is where things get interesting... A few years ago, Mythbusters did a segment about water rockets, which created a surge of interest in the sport. The surge in popularity generated a lot of wonderful research into improvements in key areas. Enthusiasts began lofting cameras and science experiments and often crashing them, since the state of the art at that time were notoriously unreliable passive and clockwork parachute deploy systems. To improve the reliability of deploy systems, a number of people turned to electronic systems, usually activating a servo motor or a magnetic release. Many designs were built and tested, and at the time there were numerous designs based on the Microchip PIC processors, which we felt were abhorrent even back then. We did some designs based on Motorola micros and some AVR designs, and then we discovered the low cost R/F development kits for the MSP430 and discovered how amazing this family of micros is. We designed a number of deploy controllers and camera controllers and other payloads for our rockets based on the EZ430-RF2500 kits. Around this time, a couple of garage shops took the best designs that were being discussed online, and they rehashed them and started producing and selling various microcontroller servo deploy timers for water rockets. Being early into a new market, quite a bit of price gouging began taking place. This type of thing flies in the face of what water rockets is all about, so we thought it would be great to publish plans on how to build a version of our servo deploy timer. As luck would have it, the MSP430 LaunchPad had just arrived on the market and so a little software work to fit our code into the small memory of the MSP430G2231 was all it would take to make our design work for everyone (Documenting the build process for the average layperson was by far the hardest part of the project). When the project was complete, we published the executable and build instructions, and thanks for the $4.30 price, people could have a servo parachute recovery system for about 10% of the price of the PIC based semi commercial offerings. We absolutely fell in love with the LaunchPad and the fact that it could be programmed easily in C or assembler, and has such a wide range of offerings. Since then, TI upgraded the LaunchPad to the MSPP430G2553, with more memory, and we decided to produce a much more advanced design. With the addition of a Sparkfun barometric sensor breakout board and a piezo buzzer, we created a LaunchPad based model rocket Altimeter with automatic parachute deploy at apogee. This past summer we published the executable and the instructions for this new version and it has been well received. That's our history in a nutshell. We hope to continue to refine and improve our DIY designs using some of the new LaunchPads which have come out recently. They come out so fast now we have a backlog of ideas to apply! This is a good problem to have! We hope you enjoyed our story, and look forward to interacting with everyone here on the forum! USWaterRockets
  7. The example "servo sweep" program under "education" does not seem to compile it gives the error ServoSweep.ino:20:20: fatal error: Servo.h: No such file or directory Anyone able to get a servo to be controlled by the cc3200 with energia?
  8. I have been getting familiar with the Tiva Launchpad and I have started working with the MPU6050. After some help from this forum, I was able to get it up and running and thought I would share some of my results. I have a goal of building a self balancing robot, but I am trying to take tiny steps to get there. Here is a short video of my progress. I am still a long way off, but I am happy to be progressing. PS, is there a way to embed youtube videos?
  9. ive compiled and uploaded my code (below) and when plug my msp430g2553 in it goes to the programmed angle it should when plugged in, but when i run the exe that is supposed to change its angle it doesnt do anything. the exe is programmed to connect to com4, and the msp430 application uart is set to com4. i know the exe can detect it because it wont run unless it can, it just isnt responding. im am using energia 0101E0010 to compile and upload. any help would be appreciated. here is the code: #include <Servo.h> Servo myServo; const int servoPin = 9; // the pin the servo is connected to int val = 0; // a value accumulated from data on the serial port int angle = 90; // the current angle of the servo void setup() { Serial.begin(9600); myServo.attach(servoPin); myServo.write(angle); // center the servo } void loop() { if ( Serial.available()) { char ch =; if(ch >= '0' && ch <= '9') // is ch a number? val = val * 10 + ch - '0'; // yes, accumulate the value else if(ch == '-') // is this the minus sign? { angle = angle - val; if(angle < 0) angle = 0; myServo.write(angle); // write the new angle val = 0; } else if(ch == '+') // is this the plus sign? { angle = angle + val; if(angle > 180) angle = 180; myServo.write(angle); // write the new angle val = 0; } } }
  10. I'm fairly new to specifically MSP430 development, so any help here is appreciated! I'm trying to send data to and from a Raspberry Pi connected over hardware UART. This I've tested and works. I'm also trying to run two servos on the MSP430 and the basic code I have for them has been tested and also works. The problem occurs when I try to put them together as my timer setup must clash somewhere. It seems to me that the serial communication is all set on TA0 while the other timer is set to TA1. I don't understand why this would prevent the UART from sending and receiving. Edit: I'm using the MSP430G2553 int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer init_servos(); init_UART(); _BIS_SR(GIE); // Enable CPU interrupts while(1){ // Wait for incoming character _BIS_SR(LPM0_bits); // Enter low poser mode if (rxBuffer == 'a') { P1OUT |= BIT0; } } } void init_UART() { DCOCTL = 0x00; // Set DCOCLK to 1MHz BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P1OUT = 0x00; // Initialize all GPIO P1SEL = UART_TXD + UART_RXD; // Timer function for TXD/RXD pins P1DIR = UART_TXD + BIT0; // TX and LED1 to Output // Configures Timer_A for full-duplex UART operation TA0CCTL0 = OUT; // Set TXD Idle as Mark = '1' TA0CCTL1 = SCS + CM1 + CAP + CCIE; // Sync, Neg Edge, Capture, Int TA0CTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode } void init_servos() { P2SEL |= BIT0 | BIT1; P2DIR |= BIT0 | BIT1; // Duty Cycle (585 - 675 - 765) TA1CCTL0 = OUTMOD_7; // reset/set (0) TA1CCTL1 = OUTMOD_7; // reset/set (1) TA1CTL = TASSEL_2 + MC_1; // SMCLK, up mode BCSCTL1 = 0x84; // CLK Info TA1CCR0 = 675; // Duty Cycle (2.0) TA1CCR1 = 675; // Duty Cycle (2.1) } void TimerA_UART_print(char *string) { // Prints a string using the Timer_A UART while (*string) TimerA_UART_tx(*string++); } void TimerA_UART_tx(unsigned char byte) { while (TACCTL0 & CCIE); // Ensure last char got TX'd TACCR0 = TAR; // Current state of TA counter TACCR0 += UART_TBIT; // One bit time till first bit TACCTL0 = OUTMOD0 + CCIE; // Set TXD on EQU0, Int txData = byte; // Load global variable txData |= 0x100; // Add mark stop bit to TXData txData <<= 1; // Add space start bit } #pragma vector = TIMER0_A0_VECTOR // Timer_A UART - Transmit Interrupt Handler __interrupt void Timer_A0_ISR(void) { static unsigned char txBitCnt = 10; TA0CCR0 += UART_TBIT; // Add Offset to CCRx if (txBitCnt == 0) { // All bits TXed? TA0CCTL0 &= ~CCIE; // All bits TXed, disable interrupt txBitCnt = 10; // Re-load bit counter } else { if (txData & 0x01) TA0CCTL0 &= ~OUTMOD2; // TX Mark '1' else TA0CCTL0 |= OUTMOD2; // TX Space '0' } txData >>= 1; // Shift right 1 bit txBitCnt--; } #pragma vector = TIMER0_A1_VECTOR // Timer_A UART - Receive Interrupt Handler __interrupt void Timer_A1_ISR(void) { static unsigned char rxBitCnt = 8; static unsigned char rxData = 0; switch (TA0IV) { // Use calculated branching case TA0IV_TACCR1: // TACCR1 CCIFG - UART RX TA0CCR1 += UART_TBIT; // Add Offset to CCRx if (TA0CCTL1 & CAP) { // Capture mode = start bit edge TA0CCTL1 &= ~CAP; // Switch capture to compare mode TA0CCR1 += UART_TBIT_DIV_2; // Point CCRx to middle of D0 } else { rxData >>= 1; if (TA0CCTL1 & SCCI) // Get bit waiting in receive latch rxData |= 0x80; rxBitCnt--; if (rxBitCnt == 0) { // All bits RXed? rxBuffer = rxData; // Store in global variable rxBitCnt = 8; // Re-load bit counter TA0CCTL1 |= CAP; // Switch compare to capture mode _BIC_SR_IRQ(LPM0_bits); // wake up from low power mode. } } break; } }
  11. Hello everyone, I'm trying to add some sound to my robot. The Energia example sketch "toneMelody" compiles without error unless you also include the library Servo.h. I have read that Arduinos have the same problem, it is because both libraries call upon the same timer. Is it possible to change the code for one of the libraries so that it uses a different timer, if one exists, so that the libraries do not conflict? I'm still a novice at all of this so any help would be much appreciated, thank you. I am using the m430g2553 chip on the Ti Launchpad MSP430 rev.1.5 board. Energia v0101e0011. Win7. simple code: #include <Servo.h> #include "pitches.h" // notes in the melody: int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4}; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 8, 8, 4,4,4,4,4 }; void setup() { // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 8; thisNote++) { // to calculate the note duration, take one second // divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 1000/noteDurations[thisNote]; tone(8, melody[thisNote],noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); // stop the tone playing: noTone(8); } } void loop() { // no need to repeat the melody. } Error message when code is compiled: core.a(Tone - Copy.cpp.o): In function `TIMER0_A0_ISR()': C:\TiLaunchpad\energia-0101E0011-windows\energia-0101E0011\hardware\msp430\cores\msp430/Tone - Copy.cpp:208: multiple definition of `__isr_9' Servo\Servo.cpp.o:C:\TiLaunchpad\energia-0101E0011-windows\energia-0101E0011\hardware\msp430\libraries\Servo/Servo.cpp:89: first defined here collect2: ld returned 1 exit status
  12. Hello, i would like to control servo with web interface, but instead of turning up/down/right/left with buttons use JS or flash drag'n'drop joystick ( Is there any tutorials on this topic? Thanks in advance, Alex
  13. I ordered a few tower pro mg995 servos and was only able to control them through 120 deg. But when its powered off, I can manually turn the servo horn through 180. Has anyone figured out how to control through the 180, or is it just not possible? Thanks
  14. When programming recently, I found that I had some trouble controlling a motor at the same time as several servo. The servos would go all crazy, and the motor wouldn't work. I guessed that this was because the timers were interfering, or not enough timers, or similar. Digging into the servo library, and the analogWrite function, I found that they're both trying to use Timer A. Thus, I modified the analogWrite function. In file energia/hardware/msp430/cores/msp430/wiring_analog.c , I commented out lines 110 to 123 (inclusive). Below is the code commented out. case T0A1: // TimerA0 / CCR1 TA0CCR0 = PWM_PERIOD; // PWM Period TA0CCTL1 = OUTMOD_7; // reset/set TA0CCR1 = PWM_DUTY(val); // PWM duty cycle TA0CTL = TASSEL_2 + MC_1 + analog_div; // SMCLK, up mode break; #if defined(__MSP430_HAS_TA3__) || defined(__MSP430_HAS_T0A3__) case T0A2: // TimerA0 / CCR2 TA0CCR0 = PWM_PERIOD; // PWM Period TA0CCTL2 = OUTMOD_7; // reset/set TA0CCR2 = PWM_DUTY(val); // PWM duty cycle TA0CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode break; #endif This may only work using the G2553, but if you're stuck with a G2231 from a rev 1.4 board, just sample a new chip
  15. hi, i'm very very newbie with 32bits microcontrollers, i just have experience working with 8bits avr microcontrollers, mi question is, exist a library for servos that can i use in my stellaris launchpad? (i understand servos and pwm) and if not, how can i use servos with my board? timer??
  16. Hi. First of all I would like to thank developers and supporters of Energia as well as for their wonderful efforts. I have worked on Arduino for quite a bit of time now and am now trying on the MSP430, of course using the launchpad. Recently, I wrote a code in Arduino which reads the value of 4 push-to-on switches and positions the servo according to the switch state. For example, following cases happen : if no switch is pressed, the servo remains at 0, if two switches are pressed, servo moves to say 30 degrees and so on. For this, I have used switch-case control, switching the total sum of switch states, which were stored in an integer array. Now the problem is that this code works perfectly with Arduino, but when tried with Energia on MSP430G2553, the servo oscillates between 2 or three values randomly and never gets a fixed position. The serial monitor shows different values for example, 2, 3, 3, 4, 2, 3,...... and the servo will oscillate between these values according to the switch case. This all happens irrespective of the switch states. I think my code is fine as it works perfectly in Arduino and i have checked all the pin assignments and the connections a million times but nothing gets this to work. May be I am missing something in the transition from Arduino to MSP430 or something else is wrong. Please correct me where I am wrong. Also if anyone thinks this approach is not good enough and has a better idea is welcome to share. Thanks Smat // servo control using switches at 3 4 5 6 for #include <Servo.h> int sen[]={3,4,5,6}; //switch connections Servo myservo; //servo object int pos = 0; // variable to store the servo position unsigned int sum; int f, r, t, m; int load[]={f, r, t, m}; // array to store switch values 0 or 1 void setup() { for(int i= 0; i< 4; i++) { pinMode(sen[i], INPUT); // declare pushbutton as input digitalWrite(sen[i],HIGH); // internal pull up enable Serial.begin(9600); } myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { sum=0; // int vairable to store the sum of load array for(int j=0; j<4; j++) { load[j]=digitalRead(sen[j]); sum = sum + load[j]; delay(30); } Serial.print(sum); Serial.println(); switch(sum) { case 0: myservo.write(100); //delay(2000); break; case 1: myservo.write(75); //delay(2000); break; case 2: myservo.write(50); //delay(2000); break; case 3: myservo.write(25); //delay(2000); break; case 4: myservo.write(0); //delay(2000); break; //default: //delay(500); } }
  17. Hi guys, i want to make a little project to create a 360°photography tool. My dad has a brand new Stellaris Launch Pad LM4F120, so i want to make it with this piece of hardware. My idea is to control a servo (TowerPro MG995) that will rotate a white desk, where i will have placed for example a Phone. I need to program stellaris to rotate the desk for 22,5°then send a signal to a DSLR to make a photo, then rotate the desk further for 22,5°then make a photo and soo, till i get 16 photos of the phone so i can create a 360°photo. I am new at ARM programing so i need your help to point me to some materials, where i can learn this stuff. Maybe some ol projects to control a digital servo. Thx and hope somebody will answer