Archive for the ‘ARDUINO’ Category

Pengetesan motor servo menggunakan Arduino 1.5.2

//inilah contoh programnya yang diambil dan dimodifikasi dari arduino example.

// Sweep
// by BARRAGAN <http://barraganstudio.com&gt;
// This example code is in the public domain.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos < 50; pos += 1)  // goes from 0 degrees to 180 degrees
{                                  // in steps of 1 degree
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                       // waits 15ms for the servo to reach the position
}
for(pos = 50; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
{
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                       // waits 15ms for the servo to reach the position
}
//    myservo.write(0);              // tell servo to go to position in variable ‘pos’

}

Update materi dan bahan praktikum EMBEDDED SYSTEM

Semua program dibangun dengan menggunakan ARDUINO 1.0.1 dan koding program dapat diunduh disini

Pertemuan ke-7 – Embedded System – Membuat Tulisan Nama dan NIM Bergerak/Bergeser pada LCD

/*

Berikut adalah program untuk menampilkan tulisan bergeser

oleh: Budi Rahmani

untuk mata kuliah Embedded System – STMIK Banjarbaru – Sem Gasal 2012-2013

The circuit:
* LCD RS pin to digital pin 13
* LCD Enable pin to digital pin 12
* LCD D4 pin to digital pin 11
* LCD D5 pin to digital pin 10
* LCD D6 pin to digital pin 9
* LCD D7 pin to digital pin 8

* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Continue reading

Pertemuan ke-5 – Menjalankan modul LCD 16×2 pada Arduino Board ATmega168

Berikut contoh program untuk mengakses LCD modul dengan konfigurasi berikut ini:

/*

Arduino version 1.0.1
The circuit:
* LCD RS pin to digital pin 13
* LCD Enable pin to digital pin 12
* LCD D4 pin to digital pin 11
* LCD D5 pin to digital pin 10
* LCD D6 pin to digital pin 9
* LCD D7 pin to digital pin 8

* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
* last modified by Budi R – 2 Oktober 2012
*/

// include the library code:
#include <LiquidCrystal.h>

//data to LCD modul
char baris0[]=”STMIK BANJARBARU”;
char baris1[]=”tesLCD 15 Okt’12”;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13,12,11,10,9,8); //pin RS,Enable,D4,D5,D6,D7

void setup()
{
// set up the LCD’s number of columns and rows:
lcd.begin(16,2);
}

void nyalaLCD()
{
// set up the LCD’s number of columns and rows:
lcd.setCursor(0, 0);
lcd.print(baris0);
lcd.setCursor(0, 1);
lcd.print(baris1);

}

void loop()
{
nyalaLCD();
}

Continue reading

Menghubungkan Sensor SRF-05 dan LCD modul 16×2

Berikut contoh code untuk menghubungkan Sensor SRF dan LCD modul 16×2 pada arduino board ATmega168

#include <LiquidCrystal.h>

int baris1;  //OK untuk memberi data ke LCD

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(8,9,10,11,12,13);

/*  The circuit:
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 10
* LCD D5 pin to digital pin 11
* LCD D6 pin to digital pin 12
* LCD D7 pin to digital pin 13
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)

*/
//SRF05 sample code//
int duration;                                                          //Stores duration of pulse in
int distance;                                                        // Stores distance
int sensorpin = 7;                                                 // Pin for SRF05 (dihubungkan ke pin7)

void setup()
{
Serial.begin(9600);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
}

void loop()
{
pinMode(sensorpin, OUTPUT);
digitalWrite(sensorpin, LOW);                          // Make sure pin is low before sending a short high to trigger ranging
delayMicroseconds(2);
digitalWrite(sensorpin, HIGH);                         // Send a short 10 microsecond high burst on pin to start ranging
delayMicroseconds(10);
digitalWrite(sensorpin, LOW);                                  // Send pin low again before waiting for pulse back in
pinMode(sensorpin, INPUT);
duration = pulseIn(sensorpin, HIGH);                        // Reads echo pulse in from SRF05 in micro seconds
distance = duration/58;                                      // Dividing this by 58 gives us a distance in cm
Serial.println(distance);                                              // Wait before looping to do it again
delay(100);

baris1=abs(distance);  //mengonversi menjadi nilai absolut
lcd.setCursor(0, 0);
lcd.print(”                “);  //membersihkan tampilan LCD
lcd.setCursor(0, 0);            //menyiapkan LCD baris1
lcd.print(baris1);              //menulis variabel distance dg variabel baris1
delay(10);
}

Arduino wild thamper with 5 x SRF-05 and 4 DC GEARBOX MOTOR

//HERE IS THE CODE

/* Program mengetes motor DC pada wild thumper ATMega168 controller
27 April 2012 – 21.00 WITA
*/

const int buttonPin= 2;     // the number of the sensor input
const int ledPin   = 13;      // the number of the LED pin
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status Continue reading

2×16 LCD display untuk pemula dengan arduino ATmega168

//Berikut contoh aplikasi arduino LCD modul yang sudah dimodifikasi menyesuaikan dengan ATMega168 wild Thumpler controller module.

/*
LiquidCrystal Library – Hello World

Demonstrates the use a 16×2 LCD display.  The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch prints “Hello World!” to the LCD
and shows the time.

The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 10
* LCD D4 pin to digital pin 7
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 8
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)

Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 26 Apr 2012
Budi Rahmani – Connected to arduino wild thumpler

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 10, 7 , 4, 8, 2);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(” Hibah Bersaing “);

}

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
//  lcd.print(millis()/1000);
lcd.print(”  Tahun   2012  “);

}