(SKU:RB-01C082)StarDuino v1.0 Controller

From ALSRobot-Wki
Jump to: navigation, search
StarDuino01.jpg

Contents

An overview of the

StarDuino v1.0 predominantly ATmega32U4 chip of multi-function control panel. StarDuino not only has complete compatible Arduino Leonardo features, has integrated the two motor driven, 4 road steering gear drive, simulated IO extension mouth, I2C bus interface, serial interface, and other functions.

Product parameters

  • Micro controller:ATmega32u4
  • bootloader:Arduino Leonardo
  • Working voltage:5V
  • Dc output:5V/3.3V
  • input voltage (recommended):7-12V
  • input voltage (limit):6-24V
  • Digital port external power supply voltage:5-20V
  • Digital I/O(digital):23
  • Analog I/O(simulation):12
  • IO pin dc current:40mA
  • 3.3 V dc current pin:50mA
  • Constant output current motor driver module:2A
  • volume:89x79x20mm

Function description

1.Digital I/O(digital): D0-D16,A0-A5
2.Analog I/O(simulation): A0-A5,A6-A11(digital4,6,8,9,10,12))
3.PWM口:7 (Digital pins3,5,6,9,10,11,13)
4.Support USB power supply with an external power supply switch
5.Support the ISP download function
6.Support 1 set of I2C/TWI interface
7.Motor driver support 2 road, peak current 2 a, 6 control I/O switching jumper
8.Support 4 road steering gear drive
9.Buzzer driver support 1 road


Pin description

StarDuino02.jpg

basic experimental

Arduino IDE use

Arduino IDE is Arduino products software editing environment. Simple said is to use it to write code, download code of the program. Any product based on the Arduino download code to run. We have set up the hardware circuit is auxiliary code to complete, both are short of one cannot. As a man through the brain to control body activity is a truth. If the program controller is brain, peripheral hardware is the physical, the activities of the body depends on the brain, so the hardware implementation depends on the functional code.

onboard (L)Light experiment

StarDuino like the Arduino, a connection to the digital port 13 on-board test LED (L)! After the StarDuino connected to the computer, open the Arduino IDE, select the card to the Arduino Leonardo and serial interface - > COM port number (as shown in figure 2).
StarDuino03.jpg

Note: this interface requires you to find my computer icon to click the right mouse button, choose 】 【 manage 】
Demo code:

int ledPin = 13;                     // 定义LED为pin13

void setup()
{
    pinMode(ledPin, OUTPUT);       // 设置数字端口13为输出模式
}

void loop()
{
    digitalWrite(ledPin, HIGH);   // 数字端口置高,LED亮
    delay(1000);                     // 延时
    digitalWrite(ledPin, LOW);    // 数字端口置低,LED灭
    delay(1000);                     // 延时
}


Program features:Onboard L light flashes once per second.
Note: this example program can 【 Arduino IDE - file - > example - 01. Basics to Blink 】 found; You can also use the Arduino other sample program.

Button and LED the experiment

Interactive experiment, do a simple button press, onboard L lights, loosen, onboard L lights. As shown in figure 3 wiring connection big keys.

StarDuino04.jpg


Demo code:

int buttonPin = A0;     // 定义按键为 pin A0  
int ledPin =  13;        // 定义LED为 pin 13

int buttonState = 0;    //定义并初始化按键状态

void setup() 
{
    pinMode(ledPin, OUTPUT);     // 设置数字端口13为输出模式  
    pinMode(buttonPin, INPUT);   // 设置数字端口14为输入模式    
}

void loop()
{
    buttonState = digitalRead(buttonPin);  //读取Pin 14的状态

if(buttonState == HIGH) //判断是否为高
{      
        digitalWrite(ledPin, HIGH);   //如果是高,设置L灯亮
    } 
else 
{
        digitalWrite(ledPin, LOW);    //如果是低,设置LED灯灭
    }
}


Program features: press the lights, loosen the lights went out.

Steering gear test

If you want to make things move without putting pen to paper in mechanical or electrical control. This section of the experiment is to use the Arduino to provide Servo library a steering gear control experiments. Please put the steering gear connected to the controller as shown in figure 4.

StarDuino05.jpg
#include <Servo.h>       // 声明调用Servo.h库

Servo myservo;           // 创建一个舵机对象

int pos = 0;             // 变量pos用来存储舵机位置
  
void setup() 
{ 
    myservo.attach(10);  // 将引脚10上的舵机与声明的舵机对象连接起来
} 
 
void loop() 
{ 
for(pos = 0; pos < 180; pos += 1) // 舵机从0°转到180°,每次增加1°
{            
        myservo.write(pos);              // 给舵机写入角度   
        delay(15);                         // 延时15ms让舵机转到指定位置
    }
    
for(pos = 180; pos >= 1; pos -= 1) // 舵机从180°回到0°,每次减小1°
{                                    
        myservo.write(pos);              // 写角度到舵机     
        delay(15);                         // 延时15ms让舵机转到指定位置
    } 
}


Program features: steering gear from 0 ° to 180 °, return again from 180 ° 0 °.

More steering gear experimental

StarDuino digital port expansion socket is designed according to the steering gear line sequence, so it can directly control the steering gear. Pick up small steering gear because the current is within four (less than 2 a) the total current runtime, so you can use StarDuino power supply for the moment, but if StarDuino controller to control multiple large current steering gear, using StarDuino power supply is not enough, this is where the power supply from the steering gear control port external power input end, the power supply voltage depends on the normal work of the steering gear you need.
Before experiment, please read the instructions to prevent damage to the controller, and follow the link as shown in figure 5 circuit to connect.

StarDuino06.jpg


Demo code:

#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;

void setup()
{
    servo1.attach(10);               //定义舵机1控制口为Pin10
    servo2.attach(11);               //定义舵机2控制口为Pin11
    servo3.attach(12);               //定义舵机3控制口为Pin12
    Serial.begin(19200);             //设串口0置波特率
    Serial.print("Ready");
}

void loop()
{
    static int v = 0;
    if ( Serial.available()) 
{
        char ch = Serial.read();       //读取串口数据
        switch(ch) 
{
            case '0'...'9':
            v = v * 10 + ch - '0';  //字符换算成10进制
            break;
            case 'a':             //如果数据后带a,则表示是servo1的数据,比如串口发送85a
            servo1.write(v);
            v = 0;
            break;
            case 'b':             //如果数据后带b,则表示是servo2的数据,比如串口发送90b 
            servo2.write(v);
            v = 0;
            break;      
            case 'c':             //如果数据后带c ,则表示是servo3的数据,比如串口发送180c
            servo3.write(v);
            v = 0;
            break;
        }
    }
}


Program function: through the serial port in the IDE assistant, sending the steering gear power control of the rotary Angle of steering gear, such as sending characters 85 a for steering gear 1 turn 85 degrees, send characters 180 c said steering gear 3 rotating 180 degrees.
Note: how to open the serial port?
Open the Arduino IDE, the top right corner has a magnifying glass icon, mouse on above shows a serial port monitor, click on the icon.

StarDuino07.jpg


After open the serial port, set the baud rate of serial port monitor for 19200.

StarDuino08.jpg


Can directly from the value of the corresponding input serial port, such as we input "85 a" here, let's first turn 85 ° steering gear.

StarDuino09.jpg

Motor drive experiment

StarDuino used 2 road motor drive, single peak is 2 a, use L298P control chip, the power of the motor directly provided by the StarDuino total power.
Motor control pin with features that are shown in table 1 below:


Table 1: function and motor control pin description table

StarDuino10.jpg


Motor driver circuit short-circuit jump can use control end cap for gate, and use it every time you get through, can be disconnected when not in use. Two motor wiring note will be the same as two control line to access control panel of the motor control interface.
Demo code:

int E1 = 5;     //定义M1使能端
int E2 = 6;     //定义M2使能端

int M1_2 = 4;    //定义M1控制端
int M1_1 = 7;    //定义M1控制端

int M2_1 = 8;    //定义M2控制端
int M2_2 = 9;    //定义M2控制端

void stop(void)//停止
{                 
    digitalWrite(E1,LOW);   
    digitalWrite(E2,LOW);      
}  

void advance(char a,char b)             //前进
{           
       analogWrite (E1,a);              //PWM调速
       digitalWrite(M1_2,HIGH);
       digitalWrite(M1_1,LOW);    
       analogWrite (E2,b);    
       digitalWrite(M2_1,HIGH);
       digitalWrite(M2_2,LOW);
}  
void back_off (char a,char b)           //后退
{          
    analogWrite (E1,a);
    digitalWrite(M1_2,LOW);
        digitalWrite(M1_1,HIGH);     
    analogWrite (E2,b);    
    digitalWrite(M2_1,LOW);
        digitalWrite(M2_2,HIGH);
}
void turn_L (char a,char b)             //左转
{           
    analogWrite (E1,a);
    digitalWrite(M1_2,LOW);
        digitalWrite(M1_1,HIGH);     
    analogWrite (E2,b);    
    digitalWrite(M2_1,HIGH);
        digitalWrite(M2_2,LOW);
}
void turn_R (char a,char b)             //右转
{           
    analogWrite (E1,a);
    digitalWrite(M1_2,HIGH);
        digitalWrite(M1_1,LOW);    
    analogWrite (E2,b);    
    digitalWrite(M2_1,LOW);
        digitalWrite(M2_2,HIGH);
}

void setup(void) 
{ 
    int i;                       //定义一个临时变量

    for(i = 4;i <= 9;i++)        //PIN4-PIN9管脚初始化
    {
        pinMode(i, OUTPUT);
    }
      
    Serial.begin(9600);          //设置串口0波特率
} 

void loop(void) 
{ 
    if(Serial.available() > 0)   //判断串口是否接收到数据
    {
        char val = Serial.read();//读取串口数据

        if(val!=-1)
        {
            switch(val)
            {
             case 'w'://前进
                    advance (100,100);   //PWM调速
                    break;
             case 's'://后退
                     back_off (100,100);
                     break;
             case 'a'://左转
                     turn_L (100,100);
                     break;       
             case 'd'://右转
                     turn_R (100,100);
                     break;          
            }     
         delay(40); 
        }
     else stop();  
    }
}


Program features: serial input "w", "s", "a", "d", electricity opportunities have corresponding action.

Products related to recommend

Buy address:StarDuino

Personal tools
Namespaces

Variants
Actions
Navigation
Tools