Infrared distance sensor (GP2Y0A21YK0F) [S036]



https://www.youtube.com/watch?v=GhNwmtpVTY4


*GitHubhttps://github.com/rdiot/rdiot-s036.git


* Specs

operating voltage: 4.5 V to 5.5 V

average current consumption: 30 mA (typical)

distance measuring range: 10 cm to 80 cm (4" to 32")

output type: analog voltage

output voltage differential over distance range: 1.9 V (typical)

response time: 38 ± 10 ms

package size: 29.5×13.0×13.5 mm (1.16×0.5×0.53")

weight: 3.5 g (0.12 oz)


* Contents

- DataSheet : http://www.sparkfun.com/datasheets/Components/GP2Y0A21YK.pdf


- Connect 

Yellow ----- A0

Black ----- GND

Red ----- 5V


- Key Code

int pin = A0;


int I = analogRead(pin);

int value = (6762 /(I-9)) -(4);


lcd.print("distance=" + (String)value + "CM  ");

'2) Sensor > Distance' 카테고리의 다른 글

Infrared distance sensor (GP2Y0A21YK0F) [S036]  (0) 2019.02.23
Ultrasonic Ranging Module (HC-SR04) [S011]  (0) 2016.09.08
Posted by RD IoT RDIoT

댓글을 달아 주세요

Serial MP3 Music Player Module for Arduino (YX5300) [B208]





https://www.youtube.com/watch?v=D9rsBf1b3CM


GitHub : https://github.com/rdiot/rdiot-b208


* Specs

The module is a kind of simple MP3 player device which is based on a high-quality MP3 audio chip---YX5300. It can support 8k Hz ~ 48k Hz sampling frequency MP3 and WAV file formats.

There is a TF card socket on board, so you can plug the micro SD card that stores audio files. MCU can control the MP3 playback state by sending commands to the module via UART port, such as

switch songs, change the volume and play mode and so on. You can also debug the module via USB

to UART module. It is compatible with Arduino / AVR / ARM / PIC.


Features:

1. Support sampling frequency (kHz): 8 / 11.025 / 12 / 16 / 22.05 / 24 / 32 / 44.1 / 48

2. High quality


3. Support file format: MP3 / WAV

4. Support Micro SD card, Micro SDHC Card

5. 30 class adjustable volume

6. UART TTL serial control playback mode, baud rate is 9600bps

7. Power supply can be 3.2 ~ 5.2VDC

8. Control logic interface can be 3.3V / 5V TTL

9. Compatible with Arduino UNO / Leonardo / Mega2560 / DUE



* Contents

- interface 


- Connect 

Serial MP3 Player - Arduino

GND - GND

VCC - 5V

TX - D5

RX - D6


- Commonly Command bytes Descriptions


- tested source code 

 : https://github.com/rdiot/rdiot-b208/blob/master/SerialMp3PlayerControl.ino.ino


- Key Code

#include <SoftwareSerial.h>


#define ARDUINO_RX 5 // TX - Arduino RX

#define ARDUINO_TX 6 // RX - Arduino TX


SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);


unsigned char playmode = 1; 

  #define PLAY  1

  #define PAUSE 0

static int8_t Send_buf[8] = {0} ;

  

/************Command byte**************************/

#define CMD_NEXT_SONG 0X01

#define CMD_PREV_SONG 0X02

#define CMD_PLAY_W_INDEX 0X03

#define CMD_VOLUME_UP 0X04

#define CMD_VOLUME_DOWN 0X05

#define CMD_SET_VOLUME 0X06

#define CMD_SINGLE_CYCLE_PLAY 0X08

#define CMD_SEL_DEV 0X09

#define DEV_TF 0X02

#define CMD_SLEEP_MODE 0X0A

#define CMD_WAKE_UP 0X0B

#define CMD_RESET 0X0C

#define CMD_PLAY 0X0D

#define CMD_PAUSE 0X0E

#define CMD_PLAY_FOLDER_FILE 0X0F

#define CMD_STOP_PLAY 0X16

#define CMD_FOLDER_CYCLE 0X17

#define CMD_SET_SINGLE_CYCLE 0X19

#define SINGLE_CYCLE_ON 0X00

#define SINGLE_CYCLE_OFF 0X01

#define CMD_SET_DAC 0X1A

#define DAC_ON  0X00

#define DAC_OFF 0X01

#define CMD_PLAY_W_VOL 0X22

/*********************************************************************/


#define ROTARY_ANGLE_SENSOR A0


#define ADC_REF 5//reference voltage of ADC is 5v

#define VCC     5    //the default value of VCC of the control interface is 5v

#define FULL_ANGLE 280//full value of the rotary angle is 280 degrees


void setup() 

{

  //pinMode(2, INPUT); // Button - Paluse&Play

  Serial.begin(9600);

  mySerial.begin(9600);

  delay(500);

  attachInterrupt(0, playOrPause, RISING);//pin2 -> INT0, and the Touch Sensor 

                                          //is connected with pin2 of Arduino

  sendCommand(CMD_SEL_DEV, DEV_TF);    

  delay(200);

  sendCommand(CMD_PLAY_W_VOL, 0X0F01);

}

static int8_t pre_vol = 0x0f; 

void loop() 

{

  int degrees;

  degrees = getDegree();

    

  int8_t volume;

  /*The degrees is 0~280, should be converted to be 0~255 to control the*/

  /*brightness of LED */

  volume = map(degrees, 0, 280, 30, 0); 

  if(volume != pre_vol)

  {

    sendCommand(CMD_SET_VOLUME, volume);

    pre_vol = volume;

  }

  delay(100);

}


void sendCommand(int8_t command, int16_t dat)

{

  delay(20);

  

  Send_buf[0] = 0x7e; //

  Send_buf[1] = 0xff; //

  Send_buf[2] = 0x06; //

  Send_buf[3] = command; //

  Send_buf[4] = 0x00;//

  Send_buf[5] = (int8_t)(dat >> 8);//datah

  Send_buf[6] = (int8_t)(dat); //datal

  Send_buf[7] = 0xef; //

  for(uint8_t i=0; i<8; i++)//

  {

    mySerial.write(Send_buf[i]);  

  }

  

}


int getDegree()

{

  int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);

  float voltage;

  voltage = (float)sensor_value*ADC_REF/1023;

  float degrees = (voltage*FULL_ANGLE)/VCC;

  return degrees;

}

/*Interrupt service routine*/

void playOrPause()

{

  cli();

  if(playmode == PLAY)

  {

    playmode = PAUSE;

  sendCommand(CMD_PAUSE,0);

  }

  else

  {

    playmode = PLAY;

  sendCommand(CMD_PLAY,0);

  }

  sei();

}


- Reference

CATALEX Serial MP3 Player manual version v1.0.1

 : https://github.com/rdiot/rdiot-b208/blob/master/Serial%20MP3%20Player%20v1.0%20Manual.pdf

Serial Debug tool - SSCOM32 

 : https://github.com/rdiot/rdiot-b208/blob/master/Serial%20Debug%20tool%20-%20SSCOM32.zip

Serial MP3 Player Demo Code 

 : https://github.com/rdiot/rdiot-b208/blob/master/SerialMP3PlayerDemoCode%20for%20Arduino-1.0.zip


Posted by RD IoT RDIoT

댓글을 달아 주세요

LW-101 LED Display Water Temperature Meter Monitor [B209]





https://www.youtube.com/watch?v=1FiPwYkkRFg



* Specs

Features: 

No batteries required - The device harvests its energy from the water flow Quick and easy installation without any tools - fits with handheld showerhead Materials approved for drinking water 

Newest innovated technology to upgrade and modernize your bath room;

self powered battery free thermometer to monitor your shower temperature.

As home essential Needed - to serve and surprise your husband, wife or kids.

(Especially for families having toddlers or babies)

High-precision temperature sensor 360°rotatable waterproof led screen for better viewing.


Specification:  

Material : ABS, PC

Size : connect to standard 1/2inch hose or shower head;

Temperate Range : 32-212 ℉, 0-100℃

Weight : 80g



* Contents

- Connect 






Posted by RD IoT RDIoT

댓글을 달아 주세요