Posted on Leave a comment

how to test Digital temperature sensor DS18B20 with arduino uno

There are many types of temperature sensors, which are divided into contact type and non-contact type according to the measurement method, thermal resistance and thermocouple according to the sensor material, and analog and digital according to the working principle. The previous article introduced the analog temperature sensor LM35, and this article introduced the use of the digital temperature sensor DS18B20.

Introduction to DS18B20 DS18B20 is a commonly used digital temperature sensor, which uses an integrated chip and uses a single bus technology to effectively reduce external interference and improve measurement accuracy. The output is a digital signal, and the wiring is very convenient. It can be applied to different occasions in different ways, such as pipe type, screw type, magnet adsorption type, and stainless steel package type.

Main feature:

Use a single bus interface. Only one data line is needed for bidirectional communication.

Wide measuring range and high accuracy. The measurement range is -55 ℃ — + 125 ℃, and the accuracy is ± 0.5 ℃ in the range of -10— + 85 ℃. Multi-point networking function. Multiple DS18B20 can be connected in parallel on the only three lines to achieve multi-point temperature measurement.

Flexible power supply. Power can be obtained from the data line through internal parasitic circuits.

The measurement parameters are configurable. The measurement resolution of DS18B20 can be set to 9-12 bits through the program. Power-off protection function. It contains EEPROM, after the system is powered off, it can still save the resolution and alarm temperature settings.

  • Install the library Two libraries are used in this experiment, namely “OneWire” and “DallasTemperature”, the former is a single bus library, and the latter is a library packaged for Dallas temperature sensors based on the former.

Click “Project”-“Load Library”-“Manage Library” in the IDE, find “OneWire”, select the latest version to install. The latest version is currently 2.3.4.

  1. Experimental steps
  2. Build the circuit diagram according to the schematic diagram. The line connection is very simple. The VCC, DQ, and GND of the DS18B20 are connected to the 5V, 2, and GND of the development board, respectively. A 10K resistor is connected to VCC at one end, and DQ is connected at the other end, and the pull-up resistor is used to improve the drive capability of the I / O port.

The experimental schematic diagram is shown below:

code:

#include <OneWire.h>

#include <DallasTemperature.h>

// 数据输出脚接开发板数字引脚2

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

void setup(void)

{

  Serial.begin(9600);

  sensors.begin();

}

void loop(void)

{ 

  sensors.requestTemperatures(); // 发送命令获取温度

  Serial.print("Temperature for the device 1 (index 0) is: ");

  Serial.println(sensors.getTempCByIndex(0)); 

  delay(500); 

}

3.Connect the development board, set the corresponding port number and development board type, and download the program

Posted on Leave a comment

How to make a cheap 2.4G Arduino RC robot tank?

parts list:

1. Arduino Nano

2. Motor shield Driver L298n

3. The chassis for the tank Option №1 https://www.sinoning.com/product/robot-tank-car-chassis-platform-for-diy-caterpillar-crawler-smart-track-vehicle-for-arduino-rc-toy-remote-control

other arduino robot tank chassis see here

4. Wires connecting

5. Servo SG90

https://www.sinoning.com/product/8pcs-sg90-9g-mini-micro-servo-for-rc-250-450-helicopter-airplane-car-robot

6. Joystick PS2 remote control

7. Batteries diy

https://www.sinoning.com/?s=battery+box&product_cat=0&post_type=product&lang=en

8. Swivel servo cloud system

some arduino guide:

How to program the Arduino:

1. Download http://www.arduino.cc/en/Main/Software.

2. Download and install the library https://goo.gl/dzJ0Dd.

3. Download the driver for the Chinese Arduino CH340 and install it

4. Download the sketch (quick turns – both on video)

sketch_ps2_rabochiy_exDownload

https://imgcdn.sinoning.com/2020/05/sketch_ps2_rabochiy_ex.ino

. or download a sketch (slow corners)

sketch_ps2_rabochiy_ex_medl_povDownload

https://imgcdn.sinoning.com/2020/05/sketch_ps2_rabochiy_ex_medl_pov.ino

5. Fill in the Arduino sketch.

Posted on Leave a comment

how to make Arduino Remote Control robot Tank with WiFi Camera nRF24L01?

About

In this tutorial we will learn to build a remote controlled car / tank. We will also add a WiFi camera to make the Tank more equipped. We will use the nRF24L+ module for remote control. With this tutorial, you can learn motor control with the joystick, remote motor control, and motor control with the nRF24L01.

Part List:

Arduino Uno R3 Arduino Nano nRF24L01

nRF24L Adapter – https://www.sinoning.com/product/wireless-transceiver-nrf24l01-2-4ghz-antenna-module-for-arduino-microcontroll-module-pcb-antenna L298N Motor Driver ps2 Joystick

Tank Chassis Model 1 https://www.sinoning.com/product/robot-tank-car-chassis-platform-for-diy-caterpillar-crawler-smart-track-vehicle-for-arduino-rc-toy-remote-control Breadboard DIY plate Jumper/Wires – Battery Plug –

Battery 9V – https://goo.gl/Blc0BP

Optional (If you want to add Camera) Mini WiFi CCTV IP Camera – Mini Sg90 Servo Potentiometer –

Also Recommended other Hardwares:

Lipo Battery – https://goo.gl/2JZnmg

nRF24L Antenna

NRF24L01+PA+LNA Wireless Module with Antenna 1000 Meters Long Distance FZ0410

FPV Camera – https://goo.gl/9UM8WO

FPV Goggles – https://goo.gl/fw6c1y

Tutorials:

Tutorials about using the nRF24L+ library

Source Code

code:

transmitter-codeDownload

receiver-codeDownload

nrf24l+library

https://github.com/maniacbug/RF24

more detail

Posted on Leave a comment

SNARM with Joystick arduino code

SoftwareSerial mySerial(12, 13); // RX, TX

const int SERVOS = 4;

int PIN[SERVOS], value[SERVOS], currentAngle[SERVOS], MIN[SERVOS], MAX[SERVOS], INITANGLE[SERVOS];

Servo myservo[SERVOS];

int afrom[] = {90, 35, 135}, ato[] = {20, 140, 110}, amiddle[] = {20, 35, 135}, afinal[] = {179,75,95}, aafterfinal[] = {179,35,135};

int DELAYTIME = 200;

int servo_moving[SERVOS] = {0,0,0,0};

boolean stringComplete = false;

int bt_servo = 0;

int bt_move = 0;

int idle = 0;



void setup() {

  Serial.begin(9600);

  pinMode(3, OUTPUT);  

  digitalWrite(3, HIGH); 

  mySerial.begin(9600);
 

  init_Pins();
 

  //auto_mode();

}

void loop() {

  move_bt();

  move_joy();  

}

void init_Pins(){

  PIN[0] = 11;

  MIN[0] = 0;

  MAX[0] = 179;

  INITANGLE[0] = 90;

  PIN[1] = 10;

  MIN[1] = 35;

  MAX[1] = 179;

  INITANGLE[1] = 90;

  PIN[2] = 9;

  MIN[2] = 90;

  MAX[2] = 179;

  INITANGLE[2] = 155;

  PIN[3] = 5;

  MIN[3] = 0;

  MAX[3] = 179;

  INITANGLE[3] = 25;
 

  for (int i = 0; i < SERVOS; i++){

    myservo[i].attach(PIN[i]);

    myservo[i].write(INITANGLE[i]);

    value[i] = 0;

    idle = 0;

  }  

}

void move_bt(){ 

  checkSoftSerial();

  for (int i = 0; i < SERVOS; i++){

    currentAngle[i] = myservo[i].read();
 

    if (servo_moving[i] != 0){

      currentAngle[i] += servo_moving[i];

      currentAngle[i] = currentAngle[i] > MAX[i] ? --currentAngle[i] : currentAngle[i];

      currentAngle[i] = currentAngle[i] < MIN[i] ? ++currentAngle[i] : currentAngle[i];

      myservo[i].write(currentAngle[i]);

      delay(20);

    }

  }

}

void checkSoftSerial() {

  String str = "";
 

  if (mySerial.available()){

    for (int i = 0 ; i < 2; i++){

      str += (char)mySerial.read(); 

    }

    // the servo to move

    int value = str.toInt();

    bt_servo = value / 10;
 

    // the direction to move

    int angle = value % 10;

    if (angle == 2) bt_move = 1;

    else if (angle == 1) bt_move = -1;

    else bt_move = 0;
 

    servo_moving[bt_servo] = bt_move;

  }

}

void move_joy(){

  for (int i = 0; i < SERVOS; i++){

    value[i] = analogRead(i);

    currentAngle[i] = myservo[i].read();
 
 

    if (value[i] > 612) {

      idle = 0;      

      if (currentAngle[i] > MIN[i]) --currentAngle[i]; 

    } else if (value[i] < 412) {

      idle = 0;

      if (currentAngle[i] < MAX[i]) ++currentAngle[i]; 

    } else {

      ++idle;

    }
 

    if (idle == 100){

      myservo[i].detach();

    }

  }      
 

  for (int i = 0 ; i < SERVOS; i++){

    if (!myservo[i].attached()) myservo[i].attach(PIN[i]);

    myservo[i].write(currentAngle[i]);

  }  

  delay(20);

}

void auto_mode(){

  for (int i = 0; i < 2; i++){

    closeclaw(false);

    armfromto(afrom, ato);

    closeclaw(true);

    delay(DELAYTIME); 

    armfromto(ato, amiddle);

    delay(DELAYTIME);   

    armfromto(amiddle, afinal);

    closeclaw(false);

    delay(DELAYTIME);

    armfromto(afinal, aafterfinal);

    delay(DELAYTIME);

    armfromto(aafterfinal, afrom);

    delay(DELAYTIME);

  } 

}

void armfromto(int *arrf, int *arrt){

  int lp[3], seg = 3, sign;
 

  for (int i = 0; i < 3; i++){    

    lp[i] = abs((arrt[i] - arrf[i])/seg);

  }
 

  //delay(DALAYTIME);

  for (int i = 0; i < 3; i++){

    sign = arrt[i] - arrf[i] > 0 ? 1 : -1;

    for (int j = 0; j < lp[i]; j++){

      myservo[i].write(arrf[i]+j*seg*sign);

      delay(20);

    }

    delay(DELAYTIME);

  }

}

void closeclaw(boolean op){

  if (op){

    myservo[3].write(5);

  } else {

    myservo[3].write(30);

  }

}
Posted on Leave a comment

4DOF arduino Robotic arm ps2 mg90s SNAM2000 SNAM1900 Manual

1.step

install the ps2 rocker on the acrylic

please see the detail photo

2. connect the servo to v5 expansion board and test

because we already upload the code to arduino uno

3.install the acrylic arm with servo

click here

4.code download

click here

FAQ

1.how to install driver ch340 for arduino

please read:CH340 Windows Driver Download and Installation Guide

2. how to upload code to arduino

please read:Program An Arduino In A Few Simple Steps

or :Arduino Tutorial lesson 1

………………….

create on:2017.12.24

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….