DFRobot DFR0225 Скачать руководство пользователя страница 4

char msgs[5][15] = {
  "Right Key OK ", 
  "Up Key OK    ", 
  "Down Key OK  ", 
  "Left Key OK  ", 
  "Select Key OK" };
char start_msg[15] = {
  "Start loop "};                    
int  adc_key_val[5] ={
  30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=‐1;
int oldkey=‐1;
void setup() { 
  pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat
  Serial.begin(9600);

  /* Print that we made it here */
  Serial.println(start_msg); 
}

void loop() 
{
  adc_key_in = analogRead(0);    // read the value from the sensor  
  digitalWrite(13, HIGH);
  /* get the key */
  key = get_key(adc_key_in);    // convert into key press
  if (key != oldkey) {   // if keypress is detected
    delay(50);      // wait for debounce time
    adc_key_in = analogRead(0);    // read the value from the sensor  
    key = get_key(adc_key_in);    // convert into key press
    if (key != oldkey) {         
      oldkey = key;
      if (key >=0){
        Serial.println(adc_key_in, DEC);
        Serial.println(msgs[key]);
      }
    }
  }
  digitalWrite(13, LOW);
}
// Convert ADC value to key number
int get_key(unsigned int input)
{   
  int k;
  for (k = 0; k < NUM_KEYS; k++)
  {
    if (input < adc_key_val[k])
    {  
      return k;  
    }
  }
  if (k >= NUM_KEYS)
    k = ‐1;     // No valid key pressed
  return k;
}

Pin Allocation

"PWM Mode"

Pin

Function

Digital 4

Motor 1 Direction control

Digital 5

Motor 1 PWM control

Digital 6

Motor 2 PWM control

Digital 7

Motor 2 Direction control

"PLL Mode"

Pin

Function

Digital 4

Motor 1 Enable control

Digital 5

Motor 1 Direction control

Содержание DFR0225

Страница 1: ...ed by thousands of open source codes and can easily be expanded with Arduino Shields The integrated 2 way DC motor driver and Xbee socket allows you to start your project immediatly without the need f...

Страница 2: ...sensing switching external power input Support Male and Female Pin Header Built in Xbee socket Integrated sockets for APC220 RF Module and DF Bluetooth Module Three I2C TWI Interface Pin Sets two 90...

Страница 3: ...ng 6 12v servos with the voltage input higher than 5v it s not available to extend 5v sensor on all the digital sensor interface anymore The servo power terminal won t supply system working voltage Mo...

Страница 4: ...y if keypress is detected delay 50 wait for debounce time adc_key_in analogRead 0 read the value from the sensor key get_key adc_key_in convert into key press if key oldkey oldkey key if key 0 Serial...

Страница 5: ...ng Fig4 PWM Motor Control Pin Allocation The PWM DC motor control is implemented by manipulating two digital IO pins and two PWM pins As illustrated in the diagram above Figure 5 Pin 4 7 7 8 for old R...

Страница 6: ...1 a digitalWrite M1 LOW analogWrite E2 b digitalWrite M2 LOW void turn_L char a char b Turn Left analogWrite E1 a digitalWrite M1 LOW analogWrite E2 b digitalWrite M2 HIGH void turn_R char a char b Tu...

Страница 7: ...top PLL Control Mode The Romeo also supports PLLPhase locked loop wiki index php Phase_locked_loop control mode wiki index php File Romeov11xxx png Fig5 PLL Motor Control Pin Allocation Configuration...

Страница 8: ...e E2 HIGH analogWrite M2 m2p void setup void int i for i 6 i 9 i pinMode i OUTPUT Serial begin 19200 Set Baud Rate void loop void if Serial available char val Serial read if val 1 switch val case w Mo...

Страница 9: ...Controllers wiki index php Category Motor_Controllers MicroControllers wiki index php Category MicroControllers This page was last modified on 14 March 2016 at 04 15 Content is available under GNU Fr...

Отзывы: