Is there any sample code available for using the Orangutan Controller. I have figured out how to run the LCD based on code provided on this forum but would like to explore other areas of the controller.
Specfically, I was wondering about the use of the motor h-bridge on the Orangutan. I was also wondering if anyone has used the orangutan for i2c comminucations.
The provided examples seem a little light compared to the support available for other controller boards. The trickest part that would be nice to to have a worked example for is the use of the push buttons and the LCD in the same program. The Port sharing necessary would be useful as an example.
Since the forum was hacked I’d be willing to repost my simple LCD code if anyone could benfit from it. Just post a reuest.
It would be great if you could repost your sample code.
We are very busy preparing the release of several exciting new products, including the Baby Orangutan. Once those are out, we will focus on creating sample projects that demonstrate the uses of the Orangutan features.
In the meantime, if you have the LCD working, getting the buttons to work should not be difficult. Just have your button subroutine change the pins to inputs, read the value, and then change back to outputs. As long as you don’t call the routine in the middle of doing something with the LCD, it shouldn’t affect LCD operations.
What I’m really looking for is direction on the operation of the motor H-Bridge. I’m familiar with the L293D but the h-bridge on the Orangutan seems to be somewhat different. The only data sheet I can find on the part is not all that much help. I was hoping someone on the forum would be able to point me in the right direction.
The products you mention, especially the ‘baby orangutan’ seem interesting. Can’t wait to hear more details.
I compiled the posted code with no errors using WinAVR 20040404. BV(x) set the Bit x to 1 in a Byte of data. This nomenclature was part of a pre-existing example on the forum before most of teh posts were lost to a hacking incident a while back. I re-wrote the code, compiled and tested in on my Orangutan with no errors. The new code is below. Hope this helps. (I won’t be much help in WinAVR or Gnu GCC problems, sorry.)
// ORANGUTAN.C
/*
** LCD
*/
void LCDSendNibble( unsigned char data )
{
data &= 0x0F;
data <<= 3;
PORTB &= ~0x38;
PORTB |= (data & 0x38);
data <<= 1;
PORTD &= ~0x80;
PORTD |= (data & 0x80);
PORTD |= 0x10; // LCD_STROBE = 1;
PORTD &= ~0x10; // LCD_STROBE = 0;
_delay_loop_1( (unsigned)255 );
}
void LCDData( unsigned char data )
{
PORTD |= 0x04; // LCD_RS = 1;
LCDSendNibble( data >> 4 );
LCDSendNibble( data );
}
void LCDString( const unsigned char *str )
{
while (*str != 0) {
LCDData( *str++ );
}
}
void LCDCommand( unsigned char data )
{
PORTD &= ~0x04; // LCD_RS = 0;
LCDSendNibble( data >> 4 );
LCDSendNibble( data );
_delay_loop_1( (unsigned)255 );
LCDDelay( 2000 );
}
void LCDHexNibble( unsigned char data )
{
data &= 0x0F;
if ( data > 9 ) {
data += ('A' - '9' - 1);
}
LCDData( data + '0' );
}
void LCDHex( unsigned char data )
{
LCDHexNibble( data >> 4 );
LCDHexNibble( data );
}
void LCDInit( void )
{
DDRB |= 0x38;
DDRD |= 0x9C;
PORTD &= ~0x10; // LCD_STROBE = 0;
PORTD &= ~0x08; // r/w = 0
LCDCommand( 0x32 );
LCDCommand( 0x20 );
LCDCommand( 0x1C );
LCDCommand( LCD_COMMAND_CLEAR );
LCDDelay( 1000 );
LCDCommand( 0x28 );
LCDCommand( 0x06 );
LCDCommand( 0x0C );
}
void beep (unsigned char cycles) {
DDRB |= 1<<PB0; //make PB0 an output
long i;
while (cycles > 0) {
PORTB |= 1<<PB0; // buzzer pin high
for(i=0;i<2000;i++);
PORTB &= !(1<<PB0); // buzzer pin low
for(i=0;i<2000;i++);
cycles--;
}
return;
}
int main(void) {
long i;
DDRD |= 1<<PD1; // set PD1 to output
LCDInit(); //Initialize LCD
LCDCommand(LCD_COMMAND_LINE1); //Goto start of Line 1 on LCD
LCDString("Hello"); //Print 'Hello' on first line
LCDCommand(LCD_COMMAND_LINE2); //Goto start of Line 2 on LCD
LCDString("World:-)"); //Print 'World:-)' on second line
beep(255);
while(1) {
PORTD |= 1<<PD1; // LED on
for(i=0;i<1000000;i++);
PORTD &= !(1<<PD1); // LED off
for(i=0;i<1000000;i++);
}
return 0;
}