by dsaner » Sun Oct 11, 2009 2:30 am
by dsaner
Sun Oct 11, 2009 2:30 am
Okay - after much mucking around, I finally have it working. The one big gotcha is that the lines on the circuit board are numbered 1 - 24 and in code they need to be referenced 0 - 23, so when you are plugged into S3 you are actually at channel 2!....grrrrr
At any rate, if you download the source code from the roboard site and open it in VS2005, then right click the solution and "Add New Project" and "Win32 Console App" then use the code below, it will flash an LED hooked up to S3 (channel 2). The circuit is simple just an led with a limiting resistor to ground.
It could be that I am just stupid, but if others are challenged getting started with programming the roboard, I think a led flasher is a good place to start. Oh and you need install VC2005 SP1 Redistributable Package (
http://www.microsoft.com/downloads/deta ... laylang=en) under XP
This code will flash an LED 1000 times.
// LEDConsole.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio>
#include <conio>
#include "windows.h"
#include "roboard_dll.h"
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0;
if (rcservo_Initialize(RCSERVO_USENOCHANNEL)) {
while(i < 1000)
{
printf("set GPIO pin 2 (PWM channel 2) to high\n");
rcservo_Outp(2,1);
Sleep(1000);
printf("set GPIO pin 2 (PWM channel 2) to low\n");
rcservo_Outp(2,0);
Sleep(1000);
}
rcservo_Close();
}
return 0;
}
Okay - after much mucking around, I finally have it working. The one big gotcha is that the lines on the circuit board are numbered 1 - 24 and in code they need to be referenced 0 - 23, so when you are plugged into S3 you are actually at channel 2!....grrrrr
At any rate, if you download the source code from the roboard site and open it in VS2005, then right click the solution and "Add New Project" and "Win32 Console App" then use the code below, it will flash an LED hooked up to S3 (channel 2). The circuit is simple just an led with a limiting resistor to ground.
It could be that I am just stupid, but if others are challenged getting started with programming the roboard, I think a led flasher is a good place to start. Oh and you need install VC2005 SP1 Redistributable Package (
http://www.microsoft.com/downloads/deta ... laylang=en) under XP
This code will flash an LED 1000 times.
// LEDConsole.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio>
#include <conio>
#include "windows.h"
#include "roboard_dll.h"
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0;
if (rcservo_Initialize(RCSERVO_USENOCHANNEL)) {
while(i < 1000)
{
printf("set GPIO pin 2 (PWM channel 2) to high\n");
rcservo_Outp(2,1);
Sleep(1000);
printf("set GPIO pin 2 (PWM channel 2) to low\n");
rcservo_Outp(2,0);
Sleep(1000);
}
rcservo_Close();
}
return 0;
}