Skip to content

Instantly share code, notes, and snippets.

@0xff07
Last active February 1, 2018 15:14
Show Gist options
  • Save 0xff07/f38292fd02fa1eee9096d19483e92c8a to your computer and use it in GitHub Desktop.
Save 0xff07/f38292fd02fa1eee9096d19483e92c8a to your computer and use it in GitHub Desktop.
Transmitter part for 2018 Winer Camp "Vessels" project
#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