Category Archives: Robotics

Robotics

Arduino Uno 3

ArduinoUno3

Arduino Uno 3 is the most popular plateform for begineers in field of robotics.

It contains ATmega328 controller which already have some bootloader and can interract with UART directly.

At Digital-13 is a GPIO (General purpose input output) pin where one LED is placed which is an output device. You can use this as an output device.

Simple code for this LED blinking is following:

//*************************
//Author: Kumar Satyam
//Date: 24 June 2016
//Code No: KS1000
//Purpose: Blinking LED13
//*************************

//pinNumber 13 is connected to onboard LED
const int pinNumber = 13;

void setup() {
// put your setup code here, to run once:
pinMode(pinNumber, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(pinNumber, HIGH);
delay(1000);
digitalWrite(pinNumber, LOW);
delay(1000);
}

 

If you wish to glow individual LED controlled by ADC0:

//*************************
//Author: Kumar Satyam
//Date: 23 August 2016
//Code No: KS1002
//Purpose: ADC to Individual LED (optimized)
//*************************

const int analogPin = A0;
const int n1=200;
const int n2=400;
const int n3=600;
const int n4=800;
const int n5=1000;
int x=0;
//static int x=0;

void setup() {
for (int i=0; i<=5; i++)
pinMode(i, OUTPUT);
}

void loop()
{
int sensorReading = analogRead(analogPin);

if (sensorReading < n1) x=0;
else if (sensorReading > n1 && sensorReading < n2) x=1;
else if (sensorReading > n2 && sensorReading < n3) x=2;
else if (sensorReading > n3 && sensorReading < n4) x=3;
else if (sensorReading > n4 && sensorReading < n5) x=4;
else if (sensorReading > n5) x=5;

for (int i=0; i<=5; i++)
{
if (i==x)
digitalWrite(i, HIGH);
else
digitalWrite(i, LOW);
}

}

Next codes will be updated soon…arduino-uno-schematic

ARM INSTRUCTIONs

1. Program for checking a number for prime in ARM-7 :

AREA  text1_1,    CODE, READONLY
ENTRY

Start    ldr r0,=12345678    ;input number
mov r3,r0                                      ;copy
mov r7,#1                                     ;flag status by default 1
mov r1,r0,lsr #1                         ;storing half of the given no
mov r2,#2                                      ;divisor initialization from 2

LOOP    SUB r3,r3,r2               ;division by subtraction
CMP r3,#0                                    ;checking the remainder
moveq r7,#0                                 ;if composite clear the flag

bpl LOOP

ADD r2,#1                                      ;increment of divisor
CMP r2,r1                                       ;checking the staus of divisor

bne LOOP

mov r8,r7                                          ;setting the flag (prime: 1 and composite: 0)

STOP    b STOP

END

 

2. Program for checking a number for prime in ARM-7 :

GET STARTED WITH “C” …

C-300                Book Parrot (gif)     Book Study (gif)    Book Flying (gif)    Book Dude (gif)             Book_225x225

 Please contribute in improvement of this content. If you can add something in it or explain in better way then in comment section (bellow this text) write it with giving the point number. Your good suggestions would be considered.

C programming is not so tough if we study it in proper sequence. Once we get started in correct sequence the fear from it start to go. Now the question is “what is the correct way of learning C”. Answer is simple and well known -

  1. Learn concept and instantly apply it to write a program, run it an debug it until it is compiled well. If it does not serve your desired task, then modify it to do the desired.
  2. The next lesson must contain what you learnt till now. This is the way which make revise automatically & no extra burden remains to revise the things.
  3. During learning effort should be given only on writing a program based on the learnt concept. This improves your depth of understanding the concept.

Hence, let us start with programming. Little concept, then programming and again little concept, then programming. Note that, here I am suggesting you to read the concept, then read the task and do programming yourself. does it work? No… then correct it to work well. Do effort again and again and finally you will get success. Now you  may see our program against your program for comparative analysis. I hope it will help you to learn C in well mannered way. All the best. Proceed and learn C…

 

[Further:       Under-construction]