コード例 #1
0
    def add_arduino_code(self, ad):

        ad.loop.add_call(
            self.avg.set(0),
            for_(
                for_.i,
                for_.i < self.samples,
                1,
                self.avg.set(self.avg + Arduino.analogRead(self.analog_pin2)),
            ),
            self.analog_value2.set(self.avg / self.samples),
        )

        self.analog_pin2.arduino_setter.add_call(
            Arduino.pinMode(self.analog_pin2, Arduino.INPUT))
コード例 #2
0
    def add_arduino_code(self, ad):

        ad.setup.add_call(Arduino.analogReference(Arduino.EXTERNAL))

        ad.loop.add_call(
            self.avg.set(0),
            for_(
                for_.i,
                for_.i < self.samples,
                1,
                self.avg.set(self.avg + Arduino.analogRead(self.analog_pin)),
            ),
            self.analog_value.set(self.avg / self.samples),
        )

        self.analog_pin.arduino_setter.add_call(
            Arduino.pinMode(self.analog_pin, Arduino.INPUT)
        )