Exemplo n.º 1
0
  public void addLocalSensor(String type, int pinNumber, String tags) {
    boolean notAdded = true;

    if (type.equals("analog")) {
      for (int i = 0; i < totalAnalogSensors; i++) {
        if (analogSensorPin[i] == pinNumber) notAdded = false;
      }
      if (notAdded) {
        localSensor[totalLocalSensors] =
            new LocalSensor(
                ANALOG, pinNumber, tags + ",analogRead" + pinNumber, totalLocalSensors++);
      }
    } else {

      for (int i = 2; i < totalDigitalSensors; i++) {
        if (digitalSensorPin[i] == pinNumber) notAdded = false;
      }

      if (notAdded) {
        localSensor[totalLocalSensors] =
            new LocalSensor(
                DIGITAL, pinNumber, tags + ",digitalRead" + pinNumber, totalLocalSensors++);
        a.pinMode(pinNumber, Arduino.INPUT);
      }
    }
    localSensorsAdded = true;
  }
Exemplo n.º 2
0
  public Pachuino(PApplet parent, String device, int speed) {
    System.out.println(
        "\n---------------------\nPachuino version: " + VERSION + "\n---------------------");
    pApplet = parent;

    for (int i = 0; i < Arduino.list().length; i++) {
      System.out.println(Arduino.list()[i]);
    }
    a = new Arduino(parent, device, speed);

    for (int i = 0; i < TOTAL_DIGITAL_IN; i++) {
      a.pinMode(i, Arduino.OUTPUT);
    }

    analogSensorPin = new int[TOTAL_ANALOG_IN];
    digitalSensorPin = new int[TOTAL_DIGITAL_IN];

    remoteFeed = new int[MAX_REMOTE_FEEDS];
    dIn = new DataIn[MAX_REMOTE_FEEDS];

    localSensor = new LocalSensor[TOTAL_ANALOG_IN + TOTAL_DIGITAL_IN];
    remoteSensor = new RemoteSensor[MAX_REMOTE_SENSORS];
    pApplet.registerPre(this);
  }
Exemplo n.º 3
0
 public void digitalWrite(int pin, int val) {
   int tempValue = Arduino.HIGH;
   if (val == 0) tempValue = Arduino.LOW;
   a.digitalWrite(pin, tempValue);
 }
Exemplo n.º 4
0
 public void analogWrite(int pin, float val) {
   a.analogWrite(pin, (int) (val));
 }
Exemplo n.º 5
0
 public void analogWrite(int pin, int val) {
   a.analogWrite(pin, val);
 }
Exemplo n.º 6
0
 public int digitalRead(int pin) {
   return a.digitalRead(pin);
 }
Exemplo n.º 7
0
 public int analogRead(int pin) {
   return a.analogRead(pin);
 }