红外线不返回 1 作为正确值
Infrared not returning 1 as correct value
我正在尝试制作一种手套,当您向下转动手腕时,它会发送 1 作为红外信号,如果您向上转动手腕,它会发送 1 returns 我使用的手套为 0 javascript:
input.onGesture(Gesture.TiltDown, function () {
music.playMelody("E B C5 A B G A F ", 262)
network.infraredSendNumber(1)
light.showRing(
`blue red blue red blue blue red blue red blue`)
})
input.onGesture(Gesture.TiltUp, function () {
music.wawawawaa.play()
network.infraredSendNumber(0)
light.showAnimation(light.cometAnimation, 500)
})
我不相信那里有问题,但是当我去我的 arduino 接收红外信号并在 Serial 中打印值时,它打印为 4E5CE275On
,即使我告诉 Serial以十六进制形式打印,所以它应该是 0x1。我想也许我只是不明白它是如何工作的,所以我尝试发送 0,但得到了相同的结果。我不知道出了什么问题。这是我的代码:
#include <FastLED.h>
#include <IRremote.h>
#define NUM_LEDS 150
#define DATA_PIN 5
#define CLOCK_PIN 13
int IRpin = 7;
IRrecv irrecv(IRpin);
decode_results results;
CRGB leds[NUM_LEDS];
boolean LEDon = false;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
Serial.println("resetting");
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(84);
}
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
void loop() {
if (irrecv.decode(&results))
{
while((LEDon) == false)
{
Serial.print(results.value, HEX);
Serial.print("On");
static uint8_t hue = 0;
Serial.print("x");
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
Serial.print("x");
// Now go in the other direction.
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
}
}
}
代码正在读取信号,如果存在信号,LED 将启动 运行ning 但稍后我想使用 while(results.value) == 0)
LED 运行.
你试过了吗:
Problems with Receiving
If receiving isn't working, first make sure the Arduino is at least receiving raw codes. > The LED on pin 13 of
the Arduino will blink when IR is being received. If not, then there's
probably a hardware issue.
If the codes are getting received but cannot be decoded, make sure the
codes are in one of the supported protocols. If codes should be
getting decoded, but are not, some of the measured times are probably
not within the 20% tolerance of the expected times. You can print out
the minimum and maximum expected values and compare with the raw
measured values.
The examples/IRrecvDump sketch will dump out details of the received
data. The dump method dumps out these durations but converts them to
microseconds, and uses the convention of prefixing a space measurement
with a minus sign. This makes it easier to keep the mark and space
measurements straight.
IR sensors typically cause the mark to be measured as longer than
expected and the space to be shorter than expected. The code extends
marks by 100us to account for this (the value MARK_EXCESS). You may
need to tweak the expected values or tolerances in this case.
The library does not support simultaneous sending and receiving of
codes; transmitting will disable receiving.
来自:http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
P.S。我更愿意对此发表评论并询问,但遗憾的是我是新来的,我的声誉仍然需要一些改进:)
我正在尝试制作一种手套,当您向下转动手腕时,它会发送 1 作为红外信号,如果您向上转动手腕,它会发送 1 returns 我使用的手套为 0 javascript:
input.onGesture(Gesture.TiltDown, function () {
music.playMelody("E B C5 A B G A F ", 262)
network.infraredSendNumber(1)
light.showRing(
`blue red blue red blue blue red blue red blue`)
})
input.onGesture(Gesture.TiltUp, function () {
music.wawawawaa.play()
network.infraredSendNumber(0)
light.showAnimation(light.cometAnimation, 500)
})
我不相信那里有问题,但是当我去我的 arduino 接收红外信号并在 Serial 中打印值时,它打印为 4E5CE275On
,即使我告诉 Serial以十六进制形式打印,所以它应该是 0x1。我想也许我只是不明白它是如何工作的,所以我尝试发送 0,但得到了相同的结果。我不知道出了什么问题。这是我的代码:
#include <FastLED.h>
#include <IRremote.h>
#define NUM_LEDS 150
#define DATA_PIN 5
#define CLOCK_PIN 13
int IRpin = 7;
IRrecv irrecv(IRpin);
decode_results results;
CRGB leds[NUM_LEDS];
boolean LEDon = false;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
Serial.println("resetting");
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(84);
}
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
void loop() {
if (irrecv.decode(&results))
{
while((LEDon) == false)
{
Serial.print(results.value, HEX);
Serial.print("On");
static uint8_t hue = 0;
Serial.print("x");
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
Serial.print("x");
// Now go in the other direction.
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
}
}
}
代码正在读取信号,如果存在信号,LED 将启动 运行ning 但稍后我想使用 while(results.value) == 0)
LED 运行.
你试过了吗:
Problems with Receiving
If receiving isn't working, first make sure the Arduino is at least receiving raw codes. > The LED on pin 13 of the Arduino will blink when IR is being received. If not, then there's probably a hardware issue.If the codes are getting received but cannot be decoded, make sure the codes are in one of the supported protocols. If codes should be getting decoded, but are not, some of the measured times are probably not within the 20% tolerance of the expected times. You can print out the minimum and maximum expected values and compare with the raw measured values.
The examples/IRrecvDump sketch will dump out details of the received data. The dump method dumps out these durations but converts them to microseconds, and uses the convention of prefixing a space measurement with a minus sign. This makes it easier to keep the mark and space measurements straight.
IR sensors typically cause the mark to be measured as longer than expected and the space to be shorter than expected. The code extends marks by 100us to account for this (the value MARK_EXCESS). You may need to tweak the expected values or tolerances in this case.
The library does not support simultaneous sending and receiving of codes; transmitting will disable receiving.
来自:http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
P.S。我更愿意对此发表评论并询问,但遗憾的是我是新来的,我的声誉仍然需要一些改进:)