Luteijn/Vortex: Difference between revisions

From RevSpace
Jump to navigation Jump to search
(Created page with "===Project "Microcontrolled relay board":=== {{Project |Name=Luteijn/Vortex |Status=In progress |Contact=Luteijn |Picture=Vortex_1.jpg }} I've got a four DFRobot 'Vortex' un...")
 
Line 1: Line 1:
===Project "Microcontrolled relay board":===
===Project "Vortex":===
{{Project
{{Project
|Name=Luteijn/Vortex
|Name=Luteijn/Vortex
Line 7: Line 7:
}}
}}


I've got a four DFRobot 'Vortex' units. Basic programming via the official apps is possible, but rather limited. Luckily, the internal arduino can be directly programmed too. Unfortunately, not all the specs are available, but there are some examples to work with, although they have a quite a bit of 'magic numbers' in them.
I've got a four DFRobot 'Vortex' units. Basic programming via the official apps is possible, but rather limited. Luckily, the internal Arduino clone can be directly programmed too. Unfortunately, not all the specs are available, but there are some examples to work with, although they have a quite a bit of 'magic numbers' in them.
 
====MP3-player====
There is an MP3.player integrated in the robot. It can be controlled by sending more or less magic commands over software Serial via pin 11. Pin 2 might be connected to the player too, but my tests so far never had anything received there (like an end of song reached, or even just an 'ack').
 
An example found on the DFRobot site:
<pre>
#define MP3_VOLUME 0x10
#define TX 11
#define RX 2
#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(RX, TX);// RX, TX
void setup()
{
  delay(1000);
  mp3Init();
  mp3setVolume(30);//0~255
}
void loop()
{
  mp3player(1);
  delay(2000);
  mp3stop();
  delay(1000);
}
void mp3Init()
{
    mySerial.begin (9600);
}
void mp3setVolume(byte vol)
{
    uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x06, 0x00, 0x00, vol, 0xef};
    mySerial.write(buffer, 8);
    delay(20);
}
void mp3player(byte data)
{
    uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x03, 0x00, 0x00, data, 0xef};
    mySerial.write(buffer, 8);
    delay(20);
}
 
void mp3stop()
{
    uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x16, 0x00, 0x00, 0x00, 0xef};
    mySerial.write(buffer, 8);
}
</pre>
 
The files to play can be put on the Vortex via usb, seems the little switch next to the micro-usb socket switches this between the mp3-players mass-storage and the arduino usb-serial interface. The number passed to the player is just the index into the (FAT?) table of stored songs. So, be careful of the order these are uploaded to the memory in.
 
====Eyes====
Besides 35 predefined eye patterns, it is also possible to upload your own eye patterns.
 
The default eyes can be set as follows:
<pre>
#include <Wire.h>
#define I2C_LED_ADDRESS 0b1100000
#define I2C_WRITE  0x00
 
uint8_t serial=0;
 
void setup(){
  Wire.begin(); // join i2c bus (address optional for master)
  defined_eyes(6,1);                                                                             
  delay(2000);
}
void loop(){
  defined_eyes(1,serial);
  serial++;                                                                                       
  if(serial>=35) serial=0;                                                                       
  delay(250);                                                                                     
}
 
 
void defined_eyes(uint8_t color,uint8_t serial) {
 
  Wire.beginTransmission(I2C_LED_ADDRESS << 1 | I2C_WRITE); // transmit to device #4
  Wire.write(color&0x07); // color bits: 1 blue, 2 green, 4 red
  Wire.write(serial);  //preset eyes 0~34
  Wire.endTransmission();    // stop transmitting                                                 
}
 
</pre>
 
 
<pre>
 
 
</pre>

Revision as of 11:42, 30 January 2018

Project "Vortex":

Project Luteijn/Vortex
Vortex 1.jpg
Status In progress
Contact Luteijn
Last Update 2018-01-30

I've got a four DFRobot 'Vortex' units. Basic programming via the official apps is possible, but rather limited. Luckily, the internal Arduino clone can be directly programmed too. Unfortunately, not all the specs are available, but there are some examples to work with, although they have a quite a bit of 'magic numbers' in them.

MP3-player

There is an MP3.player integrated in the robot. It can be controlled by sending more or less magic commands over software Serial via pin 11. Pin 2 might be connected to the player too, but my tests so far never had anything received there (like an end of song reached, or even just an 'ack').

An example found on the DFRobot site:

#define MP3_VOLUME 0x10
#define TX 11
#define RX 2
#include <SoftwareSerial.h>

SoftwareSerial mySerial(RX, TX);// RX, TX
void setup()
{
  delay(1000); 
  mp3Init();
  mp3setVolume(30);//0~255
}
void loop()
{
  mp3player(1);
  delay(2000);
  mp3stop();
  delay(1000);
}
void mp3Init()
{
    mySerial.begin (9600);
}
void mp3setVolume(byte vol)
{
    uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x06, 0x00, 0x00, vol, 0xef};
    mySerial.write(buffer, 8);
    delay(20);
}
void mp3player(byte data)
{
    uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x03, 0x00, 0x00, data, 0xef};
    mySerial.write(buffer, 8);
    delay(20);
}

void mp3stop()
{
    uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x16, 0x00, 0x00, 0x00, 0xef};
    mySerial.write(buffer, 8);
}

The files to play can be put on the Vortex via usb, seems the little switch next to the micro-usb socket switches this between the mp3-players mass-storage and the arduino usb-serial interface. The number passed to the player is just the index into the (FAT?) table of stored songs. So, be careful of the order these are uploaded to the memory in.

Eyes

Besides 35 predefined eye patterns, it is also possible to upload your own eye patterns.

The default eyes can be set as follows:

#include <Wire.h>
#define I2C_LED_ADDRESS 0b1100000
#define I2C_WRITE   0x00

uint8_t serial=0;

void setup(){
   Wire.begin(); // join i2c bus (address optional for master)
   defined_eyes(6,1);                                                                               
   delay(2000);
}
void loop(){
   defined_eyes(1,serial); 
   serial++;                                                                                        
   if(serial>=35) serial=0;                                                                         
   delay(250);                                                                                      
}


void defined_eyes(uint8_t color,uint8_t serial) {

   Wire.beginTransmission(I2C_LED_ADDRESS << 1 | I2C_WRITE); // transmit to device #4
   Wire.write(color&0x07); // color bits: 1 blue, 2 green, 4 red 
   Wire.write(serial);  //preset eyes 0~34
   Wire.endTransmission();    // stop transmitting                                                  
}