Last active
February 1, 2018 15:14
-
-
Save 0xff07/f38292fd02fa1eee9096d19483e92c8a to your computer and use it in GitHub Desktop.
Transmitter part for 2018 Winer Camp "Vessels" project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include "RF24.h" | |
#define CONTROLLER_PIN A0 | |
/* Pins for nrf25l01 as transmitter*/ | |
#define PIN_CE 7 | |
#define PIN_CSN 8 | |
#define PIPE_ADDRESS 0xE8E8F0F0E1LL | |
RF24 rf24(PIN_CE, PIN_CSN); | |
/* Data to be transmitted*/ | |
int msg[1] = {512}; | |
void dump() { | |
Serial.print("msg: "); | |
Serial.println(msg[0]); | |
} | |
void setup() { | |
/* Serial port setting */ | |
Serial.begin(19200); | |
/* nrf25l01 transmitter setting */ | |
rf24.begin(); | |
rf24.setPALevel( RF24_PA_MAX ); | |
rf24.openWritingPipe(PIPE_ADDRESS); // 開啟通道和位址 | |
} | |
void loop() { | |
msg[0] = analogRead(A0); | |
dump(); | |
rf24.write(msg, sizeof(int)); | |
delay(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment