Here is the code for LC:
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------>
http://www.adafruit.com/category/63_98
This example is for a 128x64 size display using I2C to communicate
3 pins are required to interface (2 I2C and one reset)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "nRF24L01.h"
#include "RF24.h"
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define CE_PIN 9
#define CS_PIN 10
// Config Radio (CEPin, CSPin)
RF24 radio(CE_PIN, CS_PIN);
// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
int txdata[1] = {0xA5};
int val;
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000
};
void setup() {
Serial.begin(9600);
SPI.begin(); // Start the SPI buss
SPI.setClockDivider( SPI_CLOCK_DIV16 ); // Set SPI clock to 4.5MHz,
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.setAutoAck(1);
radio.setChannel(115);
//Set radio.setChannel(108); 2.508 Ghz - Above most Wifi Channels
/*The range is 2.400 to 2.525 Ghz which is 2400 to 2525 MHz (MegaHz).
The nRF24L01 channel spacing is 1 Mhz which gives 125 possible channels numbered 0 .. 124.
*/
radio.setRetries(15, 15);
radio.setPayloadSize(8);
// Open pipes to other nodes for communication
//
// This simple sketch opens two pipes for these two nodes to communicate
// back and forth.
// Open 'our' pipe for writing
// Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1, pipes[1]);
// Start listening
radio.startListening();
//speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps.
//250K Bits per second gives longest range.
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
delay(2000);
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("Starting up RF24\n");
delay(2000);
display.display();
display.clearDisplay();
radio.printDetails();
}
void loop() {
display.clearDisplay();
display.setCursor(0, 0);
val = analogRead(0);
display.print("Right stick x: ");
display.print(val);
//display.display();
display.setCursor(0, 8);
val = analogRead(1);
display.print("Right stick y: ");
display.print(val);
//display.display();
display.setCursor(0, 16);
val = analogRead(3);
display.print("Left stick x: ");
display.print(val);
//display.display();
display.setCursor(0, 24);
val = analogRead(2);
display.print("Left stick y: ");
display.print(val);
sendOrder();
display.display();
}
void sendOrder()
{
// First, stop listening so we can talk.
radio.stopListening();
// Take the time, and send it. This will block until complete
bool ok = radio.write( &val, sizeof(int) );
// Now, continue listening
radio.startListening();
// Wait here until we get a response, or timeout (10ms)
unsigned long started_waiting_at = millis();
bool timeout = false;
while ( ! radio.available() && ! timeout )
if (millis() - started_waiting_at > 10 )
timeout = true;
// Describe the results
if ( timeout )
{
// At this point the ACK did not arrived so the red LED has to be on
display.setCursor(0, 32);
display.print("Reciever offline");
}
else
{
// Grab the response, compare, and send to debugging spew
unsigned long response;
radio.read( &response, sizeof(unsigned long) );
// At this point the ACK did arrived so the green LED has to be on
display.setCursor(0, 32);
display.print("Reciever online");
}
}
Debug output in 24Mhz and 48Mhz:
STATUS = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1 = 0xffffffffff 0xffffffffff
RX_ADDR_P2-5 = 0xff 0xff 0xff 0xff
TX_ADDR = 0xffffffffff
RX_PW_P0-6 = 0xff 0xff 0xff 0xff 0xff 0xff
EN_AA = 0xff
EN_RXADDR = 0xff
RF_CH = 0xff
RF_SETUP = 0xff
CONFIG = 0xff
DYNPD/FEATURE = 0xff 0xff
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = 16 bits
PA Power = PA_MAX
Not good!
Connectio to nRF24L01+ :
CE = 9
CSE = 10
MOSI = 11
MISO = 12
SlK = 13