Submission of Intermediate report of research was announced in my school class.
Using 2SC1815 Transistor for amplifier circuit driving DC motor consist of twos. But motors are not driven. Base current has detected but motor connecting corrector wasn’t working. Current calculate is not accurate so, it might be not restricted point for driving motor.
I can’t understand the cause of error, and also can’t order code by my skills.
I think that Brain Storming is necessary for me to strive this. So I am catched up with myself. Then, I tried to clean what we made from scratch.
following next column
For Arduino using for experiment class members
They’re all under preparing an construction. Trying Arduino for members anyway is the most necessary things.
By previous plan, Bluetooth controlled two-wheeled RC car has completed building. Considering with research proceeding, not only character separated dipersal forward or backward control, but also linear control by steering controller or analog joystick is aimed to next goal for in the future.
Thinking about how to obtain an analog value of joystick or something like analog gamepad, steering controller.
Arduino noticed analog joystick as analog input by voltage revel districted from value of natural number 0 to 1023. It is not useful for directrly use of model car, Arduino’s standard API, map() function becomes it useful convert.
#include <Arduino.h>
/* Arduino DC Motor Control - PWM | H-Bridge | L298N
Example 02 - Arduino Robot Car Control
by Dejan Nedelkovski, www.HowToMechatronics.com
*/
#define enA 9
#define in1 5
#define in2 6
#define enB 10
#define in3 7
#define in4 8
int motorSpeedA = 0;
int motorSpeedB = 0;
void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop() {
int xAxis = analogRead(A0); // Read Joysticks X-axis
int yAxis = analogRead(A1); // Read Joysticks Y-axis
// Y-axis used for forward and backward control
if (yAxis < 470) {
// Set Motor A forward
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
// Set Motor B forward
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
// Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedA = map(yAxis, 470, 0, 0, 255);
motorSpeedB = map(yAxis, 470, 0, 0, 255);
}
else if (yAxis > 550) {
// Set Motor A backward
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
// Set Motor B backward
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
// Convert the increasing Y-axis readings for going backward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedA = map(yAxis, 550, 1023, 0, 255);
motorSpeedB = map(yAxis, 550, 1023, 0, 255);
}
// If joystick stays in middle the motors are not moving
else {
motorSpeedA = 0;
motorSpeedB = 0;
}
// X-axis used for left and right control
if (xAxis < 470) {
// Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value
int xMapped = map(xAxis, 470, 0, 0, 255);
// Move to left - decrease left motor speed, increase right motor speed
motorSpeedA = motorSpeedA - xMapped;
motorSpeedB = motorSpeedB + xMapped;
// Confine the range from 0 to 255
if (motorSpeedA < 0) {
motorSpeedA = 0;
}
if (motorSpeedB > 255) {
motorSpeedB = 255;
}
}
if (xAxis > 550) {
// Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value
int xMapped = map(xAxis, 550, 1023, 0, 255);
// Move right - decrease right motor speed, increase left motor speed
motorSpeedA = motorSpeedA + xMapped;
motorSpeedB = motorSpeedB - xMapped;
// Confine the range from 0 to 255
if (motorSpeedA > 255) {
motorSpeedA = 255;
}
if (motorSpeedB < 0) {
motorSpeedB = 0;
}
}
// Prevent buzzing at low speeds (Adjust according to your motors. My motors couldn't start moving if PWM value was below value of 70)
if (motorSpeedA < 70) {
motorSpeedA = 0;
}
if (motorSpeedB < 70) {
motorSpeedB = 0;
}
analogWrite(enA, motorSpeedA); // Send PWM signal to motor A
analogWrite(enB, motorSpeedB); // Send PWM signal to motor B
}
Processing is a flexible softoware sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Procesing has promoted software literacy within the visual arts and visual literacy within technology. There are tens of thousands of students, artists, desiginers, researchers, and hobbyists who use Processing for learning and prototyping.
Processing has a types of API that allows us to use every gamepad as a PC I/O Interface of USB connection, and then, also has a Serial Connecting API from PC to Arduino of USB protocol, Arduino firmata.
At first, I tried to make servo control program that uses a mouse by reffering youtube, and it works.
the code is here.
Secondary, I have succeed at getting sliders, which is gotton information data of connecting interface something like gamepad.