i am having issue getting this servo to continuously rotating
its currently running with 0 load from the 5v port off the arduino, i also have a PSU for my breadboard which is also 5V
no matter what code i try i can not get the servo continuously rotating
dose anyone have any experience with the FT6335M
Regards
Matt
For heavens sake abort that doing before You burn the Arduino, if it's not already crippled.
Never power such things from any Arduino board!
Yes, 5 volt... Have You ever heard about current, amperes? Those tiny copper strips on the board are dimensioned for milliamp currents.
It’s now being powered by a 7.4 supply but still no luck
Wawa
4
What kind of supply (current capability).
Did you share grounds.
Code and a picture could help.
Leo..
I’ve got an adjustable psu
The common ground has been shared from the arduino to the breadboard
I’ll upload the code and a diag when I get home
More than luck is needed. Please post schematics. Pen and paper is often good enough.
#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>
#include <Servo.h>
#include <EEPROM.h>
int addr = 0;
Servo myservo;
// ********** encoder pins ***************
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);
#define pin_CLK 3 // CLK A
#define pin_DT 4 // DT B
#define pin_Btn 2 // switch
int count1;
unsigned long CurrentTime, PrevEncoderTime;
enum eEncoderState {eNone, eLeft, eRight, eButton};
eEncoderState EncoderState;
int EncoderA, EncoderB, EncoderAPrev, counter;
bool ButtonPrev;
// ********** Function ***************
eEncoderState GetEncoderState();
float A, B, C, Atemp,value;
int buttonpress=0;
//****************************************
void setup() {
myservo.attach(9);
u8g2.begin();
pinMode(pin_CLK, INPUT);
pinMode(pin_DT, INPUT);
pinMode(pin_Btn, INPUT_PULLUP);
count1 = EEPROM.read(addr);
count1 = (count1, DEC);
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_logisoso28_tr); // choose a suitable font
u8g2.drawStr(3,30,"Welcome"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(300);
myservo.writeMicroseconds(1500);
}
void loop()
{
while (1)
{
EncoderState = GetEncoderState();
switch (EncoderState) {
case eNone: {
continue;
}
case eButton: {
EEPROM.write(addr, count1);
//if(buttonpress == 0)
//{
buttonpress = 1;
//}
/*
else if(buttonpress == 1)
{
buttonpress = 0;
}
String string2;
string2 = String(count1);
String col2 ="count:";
col2.concat(string2);
char charBuf2[50];
col2.toCharArray(charBuf2, 50);
delay(500);
u8g2.clearBuffer(); // clear the internal memory
//u8g2.setFont(u8x8_font_chroma48medium8_r);
u8g2.setFont(u8g2_font_logisoso28_tr); // choose a suitable font
u8g2.drawStr(3,30,charBuf2); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(300);
*/
break;
}
case eLeft: {
if(buttonpress == 0)
{
count1++;
String stringa;
stringa = String(count1);
String col ="Set: ";
col.concat(stringa);
char charBuf[50];
col.toCharArray(charBuf, 50);
u8g2.clearBuffer(); // clear the internal memory
//u8g2.setFont(u8x8_font_chroma48medium8_r);
u8g2.setFont(u8g2_font_logisoso28_tr); // choose a suitable font
u8g2.drawStr(3,30,charBuf); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
}
break;
}
case eRight: {
if(buttonpress == 0)
{
// if (DefaultValue < MaxValue) DefaultValue++;
if(count1 > 0)
{
count1--;
}
String stringb;
stringb = String(count1);
String col1 ="Set:";
col1.concat(stringb);
char charBuf1[50];
col1.toCharArray(charBuf1, 50);
u8g2.clearBuffer(); // clear the internal memory
//u8g2.setFont(u8x8_font_chroma48medium8_r);
u8g2.setFont(u8g2_font_logisoso28_tr); // choose a suitable font
u8g2.drawStr(3,30,charBuf1); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
}
break;
}
}
// control servo
if(buttonpress == 1)
{
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_logisoso28_tr); // choose a suitable font
u8g2.drawStr(3,30," Start"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(300);
for(int i =0 ; i<=count1 ; i++)
{
myservo.writeMicroseconds(2000);
delay(2000);
//myservo.writeMicroseconds(1500);
//delay(1000);
buttonpress = 0 ;
}
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_logisoso28_tr); // choose a suitable font
u8g2.drawStr(3,30," Done"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(200);
}
}
}
// ******************** Encoder with button********************
eEncoderState GetEncoderState() {
// Reading the state of the encoder
eEncoderState Result = eNone;
CurrentTime = millis();
if (CurrentTime >= (PrevEncoderTime + 5)) {
PrevEncoderTime = CurrentTime;
if (digitalRead(pin_Btn) == LOW ) {
if (ButtonPrev) {
Result = eButton; // Button pressed
ButtonPrev = 0;
}
}
else {
ButtonPrev = 1;
EncoderA = digitalRead(pin_DT);
EncoderB = digitalRead(pin_CLK);
if ((!EncoderA) && (EncoderAPrev)) { // Signal A changed from 1 to 0
if (EncoderB) Result = eRight; // B=1 => encoder rotates clockwise
else Result = eLeft; // B=0 => encoder rotates counterclockwise
}
EncoderAPrev = EncoderA; // remember the current state
}
}
return Result;
}
basically i want to turn the encoder to select a number
you hit enter and the servo turns untill X number has been reached
im trying to load BBs into airsoft magazines
system
Closed
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.