Posted on Leave a comment

RC TANK ROBOT ARM INSTALL GUIDE

Step 1

install the robot arm and remote control

please read the blog showing below:

SNARM acrylic parts install guide

Step 2

use PS2 expansion board control the arm

4 pieces servo connection:

Arm bottom-0 left servo-1 right servo-14 paw servo-15

motor connection:

power supply:

4pcs AA battery box –power for sevo 5v

2pc 18650 battery box with DC male plug-arduino uno DC port

B:Arduino PS2 expansion board Manual

code to use:

open file “PS2X_ArmCar_Shield.ino”, and upload to arduino board.

CODE FOR TEST DOWNLOAD

step 3

install robot arm to tank chassis

use two long screw to make fast the robot arm on tank….

Posted on Leave a comment

SN Arduino Hygrothermograph Hygrometer Kit +LCD1602/I2C+DHT11 Install guide

…………………..

DHT11 connect to arduino

Left 1 connect to arduino + 5V,

Left 2 is signal lines connecte to arduino 2,

Right 1 connect arduino GND

IIC LCD1602 to arduino:

GND -GND

VCC – 5V

SDA – A4

SCL – A5

………………..

Code Download:

install guide on instructable

Note:

Arduino code already upload to Arduino, just plug the wire, it will work.

Relate post:

how to find Arduino LCD1602 I2C address is 0x3f or 0x27?

…………………………………

update:2017.09.12

created:2015.12.12

Posted on Leave a comment

SNA-100-6dof arduino source code

<pre lang="”LANGUAGE”" line="”0″">#include &lt;Servo.h&gt; 
Servo myservoA; 
Servo myservoB;
Servo myservoC;
Servo myservoD;
Servo myservoE;
Servo myservoF;
int i,pos,myspeed;
int sea,seb,sec,sed,see,sef;
static int v=0;
String mycommand=""; //捕捉串口发来的指令 #auto:自动运行 #com:计算机串口控制 #stop:静止状态
static int mycomflag=2; // #auto:2 自动运行 , #com: 1 计算机控制 #stop:0 静止状态 
void myprint()
{
 sea=myservoA.read();
 seb=myservoB.read();
 sec=myservoC.read();
 sed=myservoD.read();
 see=myservoE.read();
 sef=myservoF.read();
 
 Serial.print("A=");
 Serial.print(sea);
 Serial.print(" B=");
 Serial.print(seb);
 Serial.print(" C=");
 Serial.print(sec);
 Serial.print(" D=");
 Serial.print(sed);
 Serial.print(" E=");
 Serial.print(see);
 Serial.print(" F=");
 Serial.println(sef); 
}
void myservosetup() //舵机初始化到等待状态
{
 sea=myservoA.read();
 seb=myservoB.read();
 sec=myservoC.read();
 sed=myservoD.read();
 see=myservoE.read();
 sef=myservoF.read();
 
 myspeed=500;
 for(pos=0;pos&lt;=myspeed;pos+=1)
 {
 myservoA.write(int(map(pos,1,myspeed,sea,66)));
 myservoB.write(int(map(pos,1,myspeed,seb,90)));
 myservoC.write(int(map(pos,1,myspeed,sec,50)));
 myservoD.write(int(map(pos,1,myspeed,sed,90)));
 myservoE.write(int(map(pos,1,myspeed,see,120)));
 myservoF.write(int(map(pos,1,myspeed,sef,90))); 
 delay(1);
 }
}
void setup() 
{ 
 Serial.begin(9600,SERIAL_8N1);
 
 mycomflag=2; // 机械臂默认上电状态为:2 自动运行
 myservoA.attach(3); // 控制腰部(A)的端口是~3号
 myservoB.attach(5); // 控制大臂(B)的端口是~5号
 myservoC.attach(6); // 控制小臂(C)的端口是~6号
 myservoD.attach(9); // 控制小臂旋转(D)的端口是~9号
 myservoE.attach(10); // 控制腕部(E)的端口是~10号
 myservoF.attach(11); // 控制腕部旋转(F)的端口是~11号
 
 myservoA.write(66);
 myservoB.write(90);
 myservoC.write(55);
 myservoD.write(90);
 myservoE.write(120);
 myservoF.write(90);
}
void loop() 
{ 
 while (Serial.available() &gt; 0) 
 {
 mycommand += char(Serial.read());
 delay(2);
 }
 if (mycommand.length() &gt; 0)
 {
 if(mycommand=="#auto")
 {
 mycomflag=2;
 Serial.println("auto station");
 mycommand="";
 }
 if(mycommand=="#com")
 {
 mycomflag=1;
 Serial.println("computer control station");
 mycommand="";
 myservosetup();
 }
 if(mycommand=="#stop")
 {
 mycomflag=0;
 Serial.println("stop station");
 mycommand="";
 } 
 } 
 
 if(mycomflag==1) //如果是计算机串口控制 1
 { 
 
 for(int m=0;m&lt;mycommand.length();m++) // 
 {
 char ch = mycommand[m]; //读取串口数据
 switch(ch)
 {
 case '0'...'9':
 v = v*10 + ch - '0'; //字符转换成十进制
 break;
 
 case 'a': //如果数据后带a,则表示是一号舵机的数据,比如串口发送85a
 if(v &gt;= 5 || v &lt;= 175 ) myservoA.write(v); //用于设定舵机旋转角度的语句,可设定的角度范围是0°到180°,“V”得到所输入的值而改变角度,比如85a为85度角
 v = 0;
 myprint();
 break;
 case 'b': //如果数据后带b,则表示是二号舵机的数据,比如串口发送85a
 myservoB.write(v); //用于设定舵机旋转角度的语句,可设定的角度范围是0°到180°,“V”得到所输入的值而改变角度,比如90b为90度角
 v = 0;
 myprint();
 break;
 
 case 'c': 
 if(v &gt;= 20 ) myservoC.write(v); 
 v = 0;
 myprint();
 break;
 case 'd': 
 myservoD.write(v); 
 v = 0;
 myprint();
 break;
 case 'e': 
 myservoE.write(v); 
 v = 0;
 myprint();
 break;
 
 case 'f': 
 myservoF.write(v); 
 myprint();
 v = 0;
 break;
 }
 
 } 
 mycommand=""; 
 
 } // end if(mycomflag=2)
 
 if(mycomflag==2) //如果是自动运行状态2 
 { 
 delay(3000); 
 //Serial.println("auto station"); 
 myservosetup();
 myspeed=500;
 for(pos = 0; pos &lt;=myspeed; pos += 1) 
 { 
 myservoA.write(int(map(pos,1,myspeed,66,90))); // 让A从66度旋转到90度 (可修改角度)
 myservoB.write(int(map(pos,1,myspeed,90,70))); //让B从90度旋转到40度 (可修改角度)
 delay(1); 
 }
 delay(1000);
 myspeed=500;
 for(pos = 0; pos &lt;=myspeed; pos += 1) 
 { 
 myservoC.write(int(map(pos,1,myspeed,50,65))); // 
 myservoD.write(int(map(pos,1,myspeed,90,170))); //
 myservoE.write(int(map(pos,1,myspeed,90,5))); 
 delay(1); 
 }
 myspeed=1000;
 for(pos = 0; pos &lt;=myspeed; pos += 1) 
 { 
 myservoB.write(int(map(pos,1,myspeed,70,90))); // 
 myservoC.write(int(map(pos,1,myspeed,65,50))); //
 delay(1); 
 }
 myspeed=500;
 for(pos = 0; pos &lt;=myspeed; pos += 1) 
 { 
 myservoC.write(int(map(pos,1,myspeed,50,45))); // 
 myservoD.write(int(map(pos,1,myspeed,170,90))); //
 myservoE.write(int(map(pos,1,myspeed,5,50)));
 myservoF.write(int(map(pos,1,myspeed,90,40)));
 delay(1); 
 }
 myspeed=1000;
 for(pos = 0; pos &lt;=myspeed; pos += 1) 
 { 
 myservoA.write(int(map(pos,1,myspeed,90,140))); // 
 myservoF.write(int(map(pos,1,myspeed,40,130))); 
 delay(1); 
 } 
 myspeed=500;
 for(pos = 0; pos &lt;=myspeed; pos += 1) 
 { 
 myservoA.write(int(map(pos,1,myspeed,140,90))); // 
 myservoC.write(int(map(pos,1,myspeed,45,50))); // 
 myservoB.write(int(map(pos,1,myspeed,90,70))); //
 myservoE.write(int(map(pos,1,myspeed,50,120))); //
 delay(1); 
 } 
 }
 
 if(mycomflag==0) //如果是静止状态0
 {
 myservosetup();
 }
}</pre>
Posted on Leave a comment

arduino code:Acrylic Arduino 4DOF robot arm SNM-1100

<pre lang="”LANGUAGE”">#include &lt;Servo.h&gt;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
int potpin1 = 0;
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int val1;
int val2;
int val3;
int val4;

int Value1;
int Value2;
int Value3;
int Value4;
void setup()
{
 myservo1.attach(11);
 myservo2.attach(10);
 myservo3.attach(9);
 myservo4.attach(6);
 Serial.begin(9600);
}
///////////////////////////////////////////////////
#define FILTER_N 0
int i = 0;
int Filter1() {
 int new_value;
 new_value = analogRead(potpin1);
 if (Value1 != new_value) {
 i++;
 if (i &gt; FILTER_N) {
 i = 0;
 Value1 = new_value;
 }
 }
 else
 i = 0;
 return Value1;
}
/////////////////////////////////////////////////

int j = 0;
int Filter2() {
 int new_value;
 new_value = analogRead(potpin2);
 if (Value2 != new_value) {
 j++;
 if (j &gt; FILTER_N) {
 j = 0;
 Value2 = new_value;
 }
 }
 else
 j = 0;
 return Value2;
}
////////////////////////////////////////////////////
int k = 0;
int Filter3() {
 int new_value;
 new_value = analogRead(potpin3);
 if (Value3 != new_value) {
 k++;
 if (k &gt; FILTER_N) {
 k = 0;
 Value3 = new_value;
 }
 }
 else
 k = 0;
 return Value3;
}
///////////////////////////////////////////////////////
int m = 0;
int Filter4() {
 int new_value;
 new_value = analogRead(potpin4);
 if (Value4 != new_value) {
 m++;
 if (m &gt; FILTER_N) {
 m = 0;
 Value4 = new_value;
 }
 }
 else
 m = 0;
 return Value4;
}
void loop()
{
 val1 = Filter1();
 val1 = map (val1, 0, 1023, 120, 150);
 myservo1.write(val1);
 delay(1);
 Serial.print("val1=");
 Serial.print(val1);
 Serial.print(",");

 val2 = Filter2();
 val2 = map (val2, 0, 1023, 0, 179);
 myservo2.write(val2);
 delay(1);
 Serial.print("val2=");
 Serial.print(val2);
 Serial.print(",");
 val3 = Filter3();
 val3 = map (val3, 0, 1023, 0, 179);
 myservo3.write(val3);
 delay(1);
 Serial.print("val3=");
 Serial.print(val3);
 Serial.print(",");
 
 val4 = Filter4();
 val4 = map (val4, 0, 1023, 40, 179);
 myservo4.write(val4);
 delay(1);
 Serial.print("val4=");
 Serial.print(val4);
 Serial.println(",");

}</pre>
Posted on Leave a comment

Arduino LCD thermometer code

<pre lang="”LANGUAGE”">double Fahrenheit(double celsius) 
{
 return 1.8 * celsius + 32;
} //摄氏温度度转化为华氏温度
 
double Kelvin(double celsius)
{
 return celsius + 273.15;
} //摄氏温度转化为开氏温度
 
// 露点(点在此温度时,空气饱和并产生露珠)
// 参考: [url=http://wahiduddin.net/calc/density_algorithms.htm]http://wahiduddin.net/calc/density_algorithms.htm[/url] 
double dewPoint(double celsius, double humidity)
{
 double A0= 373.15/(273.15 + celsius);
 double SUM = -7.90298 * (A0-1);
 SUM += 5.02808 * log10(A0);
 SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
 SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
 SUM += log10(1013.246);
 double VP = pow(10, SUM-3) * humidity;
 double T = log(VP/0.61078); // temp var
 return (241.88 * T) / (17.558-T);
}
 
// 快速计算露点,速度是5倍dewPoint()
// 参考: [url=http://en.wikipedia.org/wiki/Dew_point]http://en.wikipedia.org/wiki/Dew_point[/url]
double dewPointFast(double celsius, double humidity)
{
 double a = 17.271;
 double b = 237.7;
 double temp = (a * celsius) / (b + celsius) + log(humidity/100);
 double Td = (b * temp) / (a - temp);
 return Td;
}
 
#include &lt;dht11.h&gt;
#include &lt;Wire.h&gt;
#include &lt;LiquidCrystal_I2C.h&gt;
 
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
 
dht11 DHT11;
 
#define DHT11PIN 2
 
void setup()
{
 lcd.init(); // initialize the lcd 
 lcd.backlight();
 lcd.print("Waiting...");
 Serial.begin(9600); 
}
void loop()
{
 int chk = DHT11.read(DHT11PIN);
 
 switch (chk)
 {
 case DHTLIB_OK: 
 lcd.setCursor(0, 0);
 lcd.print("Temp:");
 lcd.print((float)DHT11.temperature,2);
 lcd.write(0xDF);
 lcd.print("C");
 
 lcd.setCursor(0, 1);
 lcd.print("Humidity:");
 lcd.print((float)DHT11.humidity,2);
 lcd.print("%");
 
 break;
 case DHTLIB_ERROR_CHECKSUM: 
 lcd.clear();
 lcd.print("Checksum error"); 
 delay(1000); 
 lcd.clear();
 break;
 case DHTLIB_ERROR_TIMEOUT: 
 lcd.clear();
 lcd.print("Time out error"); 
 delay(1000); 
 lcd.clear();
 break;
 default: 
 lcd.clear();
 lcd.print("Unknown error"); 
 delay(1000); 
 lcd.clear();
 break;
 }
 delay(1000);
}</pre>