Mittwoch, 20. Mai 2015

Session 6: Ich hol mal den Kohlrabi raus

Gadget-Time. vieles ist schon angekommen:
- 433Mhz RF transmitter and receiver kit Module for Raspberry Arduino ARM MCU
- Ultrasonic Module HC-SR04 Distance Measuring Transducer Sensor for Arduino
- HX1838 NEC Code Infrared Remote Control module DIY Kit
- New DHT11 Temperature and Relative Humidity Sensor Module for arduino
- Passive Buzzer Module 5V Buzzer Control Panel for Arduino AVR PIC Mega Raspberry
- RGB SMD LED Module 3 Color Light 5050 Pwm 4pin For Arduino MCU Raspberry pi ARM


Noch unterwegs:
- GY-273 HMC5883L Drei-Achse Kompass Magnetometer Sensor Modul
- LM393 Diode Licht Sensor Module 3.3-5V Eingang Detektion Helligkeit Neu
- New HC-SR501 Infrared PIR Motion Sensor Module for Arduino Raspberry pi HCSR501





RGB China LED zum leuchten bringen:

Digital 3 gpio ausgänge an LED schliessen und spielen:

                // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();
     
        // provision gpio pin #01 as an output pin and turn on
        final GpioPinDigitalOutput gpio1 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "Rot_Pin6_rechts", PinState.LOW);
        final GpioPinDigitalOutput gpio2 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_02, "Blau_Pin7_Links", PinState.HIGH);
        final GpioPinDigitalOutput gpio3 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03, "Gruen_Pin8_Links", PinState.HIGH);
     
        gpio1.setShutdownOptions(Boolean.TRUE, PinState.HIGH);
        gpio2.setShutdownOptions(Boolean.TRUE, PinState.LOW);
        gpio3.setShutdownOptions(Boolean.TRUE, PinState.LOW);
         
        System.out.println("gpio1 :" + gpio1.getPin() + ", name: " + gpio1.getName() + ", mode: " + gpio1.getPin());
        System.out.println("gpio2 :" + gpio2.getPin() + ", name: " + gpio2.getName() + ", mode: " + gpio2.getMode());
        System.out.println("gpio3 :" + gpio3.getPin() + ", name: " + gpio3.getName() + ", mode: " + gpio3.getMode());
     
          for (;;) {
              Thread.sleep(1000);
          }

---------------------

Interessant für spätere sessions:
http://aruljohn.com/blog/raspberrypi-christmas-lights-rgb-led/


Das gleiche nochmal in Analog:

    public static void testPWM() {
try {
// initialize wiringPi library
com.pi4j.wiringpi.Gpio.wiringPiSetup();

// create soft-pwm pins (min=0 ; max=100)
SoftPwm.softPwmCreate(1, 0, 100);
                        SoftPwm.softPwmCreate(2, 0, 100);
                        SoftPwm.softPwmCreate(3, 0, 100);
                     
// continuous loop
while (true) {
                         
                            for (int y=1;y<4;y++){
                                System.out.println("   0% start, pin " + y);
                         
// fade LED to fully ON
for (int i = 0; i <= 100; i++) {
SoftPwm.softPwmWrite(y, i);
Thread.sleep(100);
}

                                System.out.println(" 100% erreicht");
                             
// fade LED to fully OFF
for (int i = 100; i >= 0; i--) {
SoftPwm.softPwmWrite(y, i);
Thread.sleep(100);
}
                             
                                System.out.println("   0% erreicht");
                            }
}
} catch (Exception e) {
                    System.out.println("Exception: " + e.getMessage());
}
}








System Infos:
http://pi4j.com/example/system-info.html


http://raspberrypi.stackexchange.com/questions/14831/pi4j-changing-gpios-from-and-to-input-low-and-high

https://www.google.de/search?q=provisionDigitalMultipurposePin+PWM&oq=provisionDigitalMultipurposePin+PWM&aqs=chrome..69i57.3616j0j7&sourceid=chrome&es_sm=93&ie=UTF-8


Super seite SoftPWM + MultipurposePin:
https://github.com/MyRobotLab/myrobotlab/blob/master/src/org/myrobotlab/service/RasPi.java




Aktiver Buzzer anleitung:
http://developer-blog.net/hardware/raspberrypi/raspberry-pi-aktiver-buzzer/

Versuch den Buzzer anzusprechen - ohne Erfolg:
     public static void testBuzzer() throws InterruptedException {
     
            // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();
     
       GpioPinDigitalOutput gpio4 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "Pin8_rechts", PinState.HIGH);
       gpio4.setShutdownOptions(Boolean.TRUE, PinState.LOW);
     
          for (int i=0;i<10;i++) {
              System.out.println("start " + i);
              gpio4.high();
              Thread.sleep(1000);
              gpio4.setState(PinState.HIGH);
              Thread.sleep(1000);
              System.out.println("ende " + i);
          }
       
       
       
try {
// initialize wiringPi library
com.pi4j.wiringpi.Gpio.wiringPiSetup();

// create soft-pwm pins (min=0 ; max=100)
SoftPwm.softPwmCreate(4, 0, 100);
                     
// continuous loop
while (true) {
                            System.out.println("start");
                            SoftPwm.softPwmWrite(4, 100);  //buzzer
                            Thread.sleep(5000);
                            System.out.println("done");
}
} catch (Exception e) {
                    System.out.println("Exception: " + e.getMessage());
}
     }