Close

Hello World - Software Implementation

A project log for The Ifs - Coding: it´s child’s play!

The Ifs are educational toys that teach girls and boys how to code from the age of three.

makeroni-labsMakeroni Labs 08/22/2019 at 21:370 Comments

Here we have developed  the first "brain" code for The Ifs family.

It include:

- NFC dual reading functions

- Wireless NRF24L01 comunication

- Sensor management functions: temperature, humity, light and sound.

- Actuators management functions: vibracion, light and sound

You can find the complete code in download section. We still working in the code of our product. It is only a first "hello world" to test all the functionalities.

#include <Adafruit_NeoPixel.h>
#include <Wire.h> 
#include "pitches.h"
#include "NRF24L01.h"

//neopixels
#define  PIN 2
#define  NUMBER_OF_LEDS  2

//RF
#define TX_ADR_WIDTH    5   // 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH  1  // 32 unsigned chars TX payload

//////Slots//////
//ifs
#define getTap 1
#define darkness 2
#define faceDown 3
#define EmmaCalls 4

//thens
#define turnLight 1
#define playSound 2
#define callLiam 3

int ifSlot;
int thenSlot;
int luz=0;
int golpe;
int tap_detection;

////sound////

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

////acelerómetro////

byte Version[3];
int8_t x_data;
int8_t y_data;
int8_t z_data;
byte range=0x00;
float divi=16;
float x,y,z;

/////RF///////

unsigned char TX_ADDRESS[TX_ADR_WIDTH]  = 
{
  0x34,0x43,0x10,0x10,0x01
}; // Define a static TX address

unsigned char rx_buf[TX_PLOAD_WIDTH];
unsigned char tx_buf[TX_PLOAD_WIDTH];


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMBER_OF_LEDS, PIN, NEO_GRB + NEO_KHZ800);


FIND THE COMPLETE CODE IN DOWNLOAD SECTION

Discussions