[infostudents] HWP

  • From: Jeremias Holub <Jeremias.Holub@xxxxxxxxxxxxxxxxxxxx>
  • To: infostudents@xxxxxxxxxxxxx
  • Date: Thu, 28 Jun 2007 20:37:27 +0200

Hi,

kann uns jmd seine Hardware Lösung zum Vergleichen schicken oder könnt ihr mal unsere 
Lösung auf Fehler überprüfen und evtl testen ?
Wär sau nett, danke !

Grüße
Jonas und Jere
// Einbinden der Javelin-Klassen.
import stamp.core.*;
import LCDTerminal;

public class Blatt6_1{
       static PWM IRDiode = new PWM(CPU.pin8, 3, 3);
       static PWM LED = new PWM(CPU.pin15);

       static boolean Received;

        // Hauptroutine.
        public static void main(){
          IRDiode.stop();
          while(true) {
            IRDiode.start();
            CPU.delay(10);
            Received = CPU.readPin(CPU.pin9);
            IRDiode.stop();
            if (Received) {

            }
            else {
                LED.start();
                CPU.delay(125);
                LED.stop();
            }
          }
        }
}
// Einbinden der Javelin-Klassen.
import stamp.core.*;
import LCDTerminal;

public class Blatt6_2{
       static PWM IRDiode1 = new PWM(CPU.pin9, 3, 3);
       static PWM IRDiode2 = new PWM(CPU.pin8, 3, 3);

       static PWM LED1 = new PWM(CPU.pin15);
       static PWM LED2 = new PWM(CPU.pin14);

       static int leftSpeed = 175;
       static int rightSpeed = 175;
       static PWM ServoMotorL = new PWM(CPU.pin12,175,2304);
       static PWM ServoMotorR = new PWM(CPU.pin13,175,2304);

       static void ServoControl(int Offset, boolean leftDir, boolean rightDir) {
                        if (leftDir) {
                                leftSpeed = leftSpeed - Offset;
                        }
                        else {
                                leftSpeed = leftSpeed + Offset;
                        }
                        if (rightDir) {
                                rightSpeed = rightSpeed + Offset;
                        }
                        else {
                                rightSpeed = rightSpeed - Offset;
                        }
                        ServoMotorL.update(leftSpeed,2304);
                        ServoMotorR.update(rightSpeed,2304);
                }



       static boolean Received1;
       static boolean Received2;

        // Hauptroutine.
        public static void main(){
          IRDiode1.stop();
          IRDiode2.stop();
          while(true) {
            IRDiode1.start();
            CPU.delay(10);
            Received1 = CPU.readPin(CPU.pin9);
            IRDiode1.stop();

            IRDiode2.start();
            CPU.delay(10);
            Received2 = CPU.readPin(CPU.pin8);
            IRDiode2.stop();

            if (Received1) {
              /*DO NOTHING */

            }
            else {
                LED1.start();
                CPU.delay(125);
                LED1.stop();
                ServoControl(5,false,true);
            }


            if (Received2) {
               /*DO NOTHING */
            }
            else {
                LED2.start();
                CPU.delay(125);
                LED2.stop();
                ServoControl(5,true,false);
            }
          }
        }
}

Other related posts: