A little help with programming the MEGA168

Hello,

i’ve compiled some code to get the LV-168 working, it worked fine, can someone help me convert this code to the MEGA168?
Thanks

>###########################################################################STAR 
>   CODE 
>###########################################################################
>
>#include "WProgram.h"
>#include <OrangutanBuzzer.h>
>#include <OrangutanMotors.h>
>#include <OrangutanLCD.h>
>#include <OrangutanAnalog.h>
>
>void setup();
>void loop();
>OrangutanLCD lcd;
>OrangutanMotors motors;
>OrangutanBuzzer buzzer;
>OrangutanAnalog analog;
>
>int ledPin = 1;                // LED connected to digital pin 1
>
>// Sharp sensor variables
>int val;
>int distance=0;
>
>void setup()
>{
>     pinMode(ledPin, OUTPUT);      // sets the digital pin as output
>
>// toot the horn
>     buzzer.play("T240 L8 a gafaeada c+adaeafa <aa<bac#ada c#adaeaf4");
>
>// Startup screen
>     lcd.gotoXY(0, 0);
>     lcd.print("Welcome");
>     delay(500);
>     lcd.gotoXY(0, 1);
>     lcd.print("Arguello Family");
>     delay(1000);
>     lcd.gotoXY(0, 1);
>     lcd.print("Security Vehicle Ready");
>     delay(1000);
>     lcd.clear();
>
>// set 10-bit analog-to-digital conversion
>     analog.setMode(MODE_10_BIT);
>
>     digitalWrite(ledPin, HIGH);   // sets the LED on
>     delay(500);                  // waits
>     digitalWrite(ledPin, LOW);    // sets the LED off
>     delay(250);
>     digitalWrite(ledPin, HIGH);
>     delay(500);
>     digitalWrite(ledPin, LOW);
>}
>
>void loop()
>{
>// setup motor speed
>     int motorSpeed1 = 128;
>     int motorSpeed2 = 0;
>
>     lcd.gotoXY(0, 0);
>
>// get temperature in tenths of a degree F
>     unsigned int temp = analog.readTemperatureF();
>
>     lcd.print(temp/10);
>     lcd.print('.');
>     lcd.print(temp - (temp/10)*10);
>     lcd.print((char)223);
>     lcd.print("F  ");
>
>     delay(100);
>
>     lcd.gotoXY(0, 1);
>
>// calculate distance with Sharp sensor
>     val = analogRead(4);
>     distance = (2914/(val+5))-1;
>
>     lcd.print(distance);
>     lcd.print("cm    ");
>
>// adjust motor speed for distance reading
>     if (distance < 30) {
>       motorSpeed1 = -128;
>       motorSpeed2 = 255;
>     }
>
>     motors.setSpeeds(motorSpeed1, motorSpeed2);  // set speeds of  
>motors 1 and 2
>}
>
>int main(void)
>{
>	init();
>
>	setup();
>
>	for (;;)
>		loop();
>
>	return 0;
>}
>
>###########################################################################END 
>   CODE 
>############################################################################

Hello.

Just to clarify your post for others, you are looking to get the LV-168 code you posted above working on the original Orangutan mega168, correct? As I emailed you, the Pololu AVR libraries you are specific to the LV-168, so you will have to make a quite a few changes to get things working. I suggest you look into using Orangutan-lib, which is designed to work with the original Orangutan and implements a lot of the functionality found in the Pololu AVR library. You can then go through your program and replace calls to Pololu AVR library functions with calls to similar Orangutan-lib functions. I think this will prove much easier than attempting to rewrite the Pololu AVR library to work with the original Orangutan.

- Ben

oh i see, i didn’t get a chance to view the link you sent…i will try that…thanks Ben…

No luck Ben, i downloaded the files and not enough information to convert the code from the LV-168 to the MEGA168…any other suggestions?

Can you elaborate on what information you would need to use Orangutan-lib successfully? Orangutan-lib has routines for controlling the LCD and motor drivers.

- Ben