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
>############################################################################