Getting Started with Arduino gives you lots of ideas for Arduino projects and helps you get going on them right away.
Showing posts sorted by relevance for query arduino-for. Sort by date Show all posts
Showing posts sorted by relevance for query arduino-for. Sort by date Show all posts
Saturday 16 May 2015
Serial received di c#
Hai sobat jufrikablog nah kali ini saya akan kembali lagi memberikan tutorial habis habisan tentang serial hahahahahahaha . yaitu serial received . langsung saja berikut prakteknya
1. Buat solution baru dan buat seperti ini di visula studio anda
2. Klik 2 kali pada form load misalnya, dan masukkan program ini
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace seri1
{
public partial class Form1 : Form
{
string rxString;
int[] lokasiY = new int[100];
public Form1()
{
InitializeComponent();
}
private Graphics objGraphic;
private void Form1_Load(object sender, EventArgs e)
{
objGraphic = CreateGraphics();
if (objGraphic == null)
return;
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == “Connect”)
{
button1.Text = “Disconnect”;
serialPort1.Open();
//richTextBox1.text = “”;
//a = 0;
}
else
{
button1.Text = “Connect”;
serialPort1.Close();
}
}
void SerialPort1DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
rxString = serialPort1.ReadLine();
this.Invoke(new EventHandler(DisplayText));
}
private void DisplayText(object sender, EventArgs e)
{
richTextBox1.Text += rxString;
float tinggi = float.Parse(rxString);
tinggi = 179 – (tinggi / 1023 * 179);
// geser arraynya
for (int i = 0; i < 99; i++)
{
lokasiY[i] = lokasiY[i + 1];
}
lokasiY[99] = (int)tinggi;
}
private void timer1_Tick(object sender, EventArgs e)
{
Pen pena = new Pen(Color.Black);
int awalX = 0;
int titikMulaiX, titikMulaiY, titikAkhirX, titikAkhirY;
// hapus dulu semuanya
objGraphic.Clear(Color.White);
for (int i = 0; i < 99; i++)
{
titikMulaiX = awalX + i * 5;
titikMulaiY = lokasiY[i];
titikAkhirX = awalX + (i + 1) * 5;
titikAkhirY = lokasiY[i + 1];
objGraphic.DrawLine(pena, titikMulaiX, titikMulaiY, titikAkhirX, titikAkhirY);
}
}
}
}
3. Setelah program selesai, runningkan/jalankan programnya jika bisa dijalankan dan tidak ada eror maka lanjut ke arduino
4. buat program arduino ini dan upload ke arduino yang siertai potensio untuk mengatur tegangan input dan akan di baca di aplikasi
void setup()
{ Serial.begin(9600); }
void loop()
{ int sensorValue = analogRead(A1); delay(500); Serial.println(sensorValue, DEC); }
5. setelah itu running programnya sob ;)
ini tampilannya jika tidak menggunakan potensio
sekian semoga bermanfaat :)
Monday 23 February 2015
HARDWARE :: sensor api pengganti UVtron dan Thermal array
yaitu pake remotenya nintendo wii.
sensor api paket hemat dari remote wii ini rupanya cuman setengah harga dari UVtron+driver loh (kalo pake harga batam).
pada bagian depan dari remote ini memiliki kamera infra merah dengan spesifikasi berikut:
1. kamera resolusi 1024×768
2. Up to 4 blob (cahaya IR terang melebihi thresholdnya)
3. 100 proses gambar perdetik
3. interfacing i2c
4. output i2c berupa koordinat dari 4 blob tersebut.
1. kamera resolusi 1024×768
2. Up to 4 blob (cahaya IR terang melebihi thresholdnya)
3. 100 proses gambar perdetik
3. interfacing i2c
4. output i2c berupa koordinat dari 4 blob tersebut.
wiring cameranya:
Jika menggunakan crystal quartz (4kaki) :
bentuk jadinya
yang keren dari internet, yang tengah / yang jelek itu punya saya
cuman lum dilanjutkan, timahnya habis trus resistor ma capasitor ada dibawah pcb :p
setelah itu tinggal dihubungkan ke arduino dan pasang kaca hitam bawaannya.
jika ingin pakai library arduinonya download PVision.zip ubah ke ZIP ya
jika ingin pakai library arduinonya download PVision.zip ubah ke ZIP ya
tapi jika gak mau pakai library, ini contoh akses IR kamera nya:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | // Wii Remote IR sensor test sample code by kako // modified output for Wii-BlobTrack program by RobotFreak #include int IRsensorAddress = 0xB0; int slaveAddress; int ledPin = 13; boolean ledState = false ; byte data_buf[16]; int i; int Ix[4]; int Iy[4]; int s; void Write_2bytes(byte d1, byte d2) { Wire.beginTransmission(slaveAddress); Wire.send(d1); Wire.send(d2); Wire.endTransmission(); } void setup() { slaveAddress = IRsensorAddress >> 1; // This results in 0x21 as the address to pass to TWI Serial.begin(38400); pinMode(ledPin, OUTPUT); // Set the LED pin as output Wire.begin(); // IR sensor initialize Write_2bytes(0x30,0x01); delay(10); Write_2bytes(0x30,0x08); delay(10); Write_2bytes(0x06,0x90); delay(10); Write_2bytes(0x08,0xC0); delay(10); Write_2bytes(0x1A,0x40); delay(10); Write_2bytes(0x33,0x33); delay(10); delay(100); } void loop() { ledState = !ledState; if (ledState) { digitalWrite(ledPin,HIGH); } else { digitalWrite(ledPin,LOW); } //IR sensor read Wire.beginTransmission(slaveAddress); Wire.send(0x36); Wire.endTransmission(); Wire.requestFrom(slaveAddress, 16); // Request the 2 byte heading (MSB comes first) for (i=0;i i=0; while (Wire.available() && i < 16) { data_buf[i] = Wire.receive(); i++; } Ix[0] = data_buf[1]; Iy[0] = data_buf[2]; s = data_buf[3]; Ix[0] += (s & 0x30) < Iy[0] += (s & 0xC0) < Ix[1] = data_buf[4]; Iy[1] = data_buf[5]; s = data_buf[6]; Ix[1] += (s & 0x30) < Iy[1] += (s & 0xC0) < Ix[2] = data_buf[7]; Iy[2] = data_buf[8]; s = data_buf[9]; Ix[2] += (s & 0x30) < Iy[2] += (s & 0xC0) < Ix[3] = data_buf[10]; Iy[3] = data_buf[11]; s = data_buf[12]; Ix[3] += (s & 0x30) < Iy[3] += (s & 0xC0) < for (i=0; i { if (Ix[i] < 1000) Serial.print( " " ); if (Ix[i] < 100) Serial.print( " " ); if (Ix[i] < 10) Serial.print( " " ); Serial.print( int (Ix[i]) ); Serial.print( "," ); if (Iy[i] < 1000) Serial.print( " " ); if (Iy[i] < 100) Serial.print( " " ); if (Iy[i] < 10) Serial.print( " " ); Serial.print( int (Iy[i]) ); if (i Serial.print( "," ); } Serial.println( "" ); delay(3); } |
sumber:
https://handritoar.wordpress.com/2011/11/28/sensor-api-paket-hemat-tapi-efisien/
.
.
Subscribe to:
Posts (Atom)