Arducar – RC Car with wifi

arduino motoshield soldering action

After about 2 houres of soldering everything works well :)

Now i can control my servo & dc motor with ease

#include <servotimer1 .h>
 
ServoTimer1 servo1;
ServoTimer1 servo2;
 
void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Servo test!");
  servo1.attach(10);
  servo2.attach(9);
}
 
 
void loop() {
  Serial.print("tick");
  servo1.write(180);
  servo2.write(0);
  delay(1000);
 
  Serial.print("tock");
  servo1.write(0);
  servo2.write(180);
  delay(1000);
}
</servotimer1>

Arduino LED Matrix Control Part II

IMG_0105
IMG_0106
IMG_0108
IMG_0107

With the Arduino app you can control a led matrix over wifi on your iphone.

Later you can save your “icon” and load older ones.

Sourcecode is still a bit clunky. But it Works :)

- (void)drawRect:(CGRect)rect {
 
	CGContextRef context = UIGraphicsGetCurrentContext();
	if(isOn) {
		[color setFill];
	} else {
		[[UIColor grayColor] setFill];
	}
 
	CGContextSetLineWidth(context, 1.0);
 
	CGContextAddEllipseInRect(context, rect);
	CGContextDrawPath(context, kCGPathFillStroke);
}

Download Sourcecode

Arduino LED Matrix Controlling by iPhone

IMG_0099IMG_0100Today i ported the mac ArduinoControll app to my iPhone.

+ now you can controll the LED via the UIAccelerometer

#pragma mark UIAccelerometer delegate
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
 
	double xAcceleration = 100.0 - (acceleration.x + 1.0) * 100.0;
	double yAcceleration = 100.0 - (acceleration.y + 1.0) * 100.0;
	double zAcceleration = 100.0 - (acceleration.z + 1.0) * 100.0;
 
	accelerationX.text = [[NSString alloc] initWithFormat:@"%4.1f%", xAcceleration];
	accelerationY.text = [[NSString alloc] initWithFormat:@"%4.1f%", yAcceleration];
	accelerationZ.text = [[NSString alloc] initWithFormat:@"%4.1f%", zAcceleration];
 
 
	long xValue = map(xAcceleration, -100, 100, 0, 7);
	long yValue = map(yAcceleration, -100, 100, 0, 7);
 
	[positionX setValue:xValue];
	[positionY setValue:yValue];
 
	NSString *command = [NSString stringWithFormat:@"SET LED %d:%d:%d", (int)xValue, (int)yValue, (int)[color value]];
	[socket sendData:command];
 
}

Sourcecode of Arduino Controlling with iPhone

Arduino + Wishield + LED Matrix = a lot of fun!

socketapp.c

extern char buffer[20];
static int handle_connection(struct socket_app_state *s)
{
 
  PSOCK_BEGIN(&s->p);
  PSOCK_READTO(&s->p, '\n');
  memcpy(buffer,s->inputbuffer,20);
  memset(s->inputbuffer, 0x00, sizeof(s->inputbuffer));
  PSOCK_END(&amp;s-&gt;p);
}

main

void loop() {
  WiFi.run();
  if(strncmp(buffer, "SET LED", 7) == 0) {
 
    substr(positionX, buffer, 8,1);
    substr(positionY, buffer, 10,1);
    substr(color, buffer, 12,3);
    matrix.set(atoi(positionX),atoi(positionY), atoi(color));
    matrix.send();
}

Sending to the socket server (Cocoa, NSStream)

-(void)sendData:(NSString *)string {
 
	NSString *stringWithEnding = [NSString stringWithFormat:@"%@\n", string];
	const uint8_t * rawstring = (const uint8_t *)[stringWithEnding UTF8String];
	[oStream write:rawstring maxLength:strlen(rawstring)];
 
}

Bildschirmfoto 2009-10-21 um 21.58.01

Sourcecode of the Arduino Socket Server

Sourcecode of the Cocoa Socket Client

Sourcecode of ‘simple’ pong

led matrix protocol:

SET LED x:y:color