LilyPad 开发套件

来自Duinopeak_COM
跳转至: 导航搜索

产品简介

LilyPad是可穿戴电子积木套件的总称,套件里每一块PCB都采用紫色铺油,用导电缝纫线把每一块有相应功能的PCB小板连接起来,实现各种新奇好玩的创意。
Lilypad set front.jpg

套件清单

  • ATmega328p Board
  • LilyPad Pixel Board
  • LilyPad LED
  • LilyPad Button
  • LilyPad Light Sensor
  • Lilypad Switch
  • Lilypad Vibration
  • Lilypad Temperature
  • Lilypad Buzzer

参数

  • 处理器 ATmega168 or ATmega328
  • 工作电压 2.7V-5.5V
  • 输入电压 2.7V-5.5V
  • 数字IO脚 14 (其中6路作为PWM输出)
  • 模拟输入脚 6
  • IO脚直流电流 40 mA
  • 3.3V脚直流电流 50 mA
  • Flash Memory 16 KB (ATmega168,其中2 KB 用于 bootloader)
  • SRAM 1 KB
  • EEPROM 0.5 KB
  • 工作时钟 8 MHz

应用示例

演示1 下面的demo演示了怎样来控制LilyPad套件中的每一个PCB有趣的功能。

/* Pin Definitions */
// LEDs: white LEDs are connected to 5, 6, A2, A3, A4
int ledPins[] = {5, 6, A2, A4, A3, 9, 10, 11};
int switchPin = 2;
int buttonPin = A5;
int vibePin = 3;
int buzzerP = 7;
int buzzerN = 12;
int lightSensorPin = A6;
int tempSensorPin = A1;

/* Global variables */
int light = 100;

void setup()
{
  //STARTUP LED SEQUENCE
  for(int i=0; i<5; i++)  // This for loop will run 5 times
  {  // blink the white LEDs (first 5 LEDs in ledPins array)
    pinMode(ledPins[i], OUTPUT);  // set pin as output
    digitalWrite(ledPins[i], HIGH);  // turn LED on
    delay(250);  // wait for a quarter second
    digitalWrite(ledPins[i], LOW); // turn LED off
  }
  for(int i=5;i<8;i++)  // This for loop will run 3 times
  {   // blink the RGB LEDs (last 3 LEDs in ledPins array)
    pinMode(ledPins[i], OUTPUT);   // set the pin as an output 
    digitalWrite(ledPins[i], LOW);  // turn RGB LED on
    delay(250);  // wait a quarter second
    digitalWrite(ledPins[i], HIGH);  // turn the RGB LED off
    // Note that a HIGH turns the RGB LED off, LOW is on
    // that's backwards from the white LEDs
  }
  ////////////////////////////////////////////

  //Switch
  pinMode(switchPin, INPUT);  // set the switch as an input
  digitalWrite(switchPin, HIGH);  // enable the pull-up resistor

  //Button
  pinMode(buttonPin, INPUT);  // set the pin as an input
  digitalWrite(buttonPin, HIGH);  // enable the pull-up resistor

  //VIBE
  pinMode(vibePin, OUTPUT);  // set the pin as an output

  //Buzzer
  pinMode(buzzerP, OUTPUT);  // set both buzzer pins as outputs
  pinMode(buzzerN, OUTPUT);

  Serial.begin(9600);  // We'll output some information over serial
}

void loop()
{
  //Buzzer
  if(digitalRead(buttonPin) == 0)
  {  // if you press the button, make a short buzz
    digitalWrite(buzzerP, HIGH);
    digitalWrite(buzzerN, LOW);
    delay(1);
    digitalWrite(buzzerP, LOW);
    digitalWrite(buzzerN, HIGH);
  }
  else  // If the button is not pressed go in here
  {
    if(digitalRead(switchPin) == 0)
    {  // If the switch is on, vibrate
      digitalWrite(vibePin, HIGH);
      delay(100);
      digitalWrite(vibePin, LOW); 
    }
    
    ///LIGHT TEST
    if(analogRead(lightSensorPin) < 20){
      //if its dark, turn on all white leds...
      for(int i=0;i<5;i++)
      {
        digitalWrite(ledPins[i], HIGH);
      }
    }
    else{
      // if it's light, turn them off...
      for(int i=0;i<5;i++)
      {
        digitalWrite(ledPins[i], LOW);
      }
    }

    ///TEMP TEST 
    if(analogRead(tempSensorPin) > 160)
    {
      //if the tech puts a little hot air over the temp sensor it will raise to at least 170
      digitalWrite(ledPins[5], LOW); //Turn on red LED - to indicate "hot"
    }
    else{
      digitalWrite(ledPins[5], HIGH);  // turn the red LED off
    }
    
    /* from here on down, we'll just print out the status of every input */
    Serial.print("Switch=");
    Serial.print(digitalRead(switchPin));

    Serial.print("  Temp=");
    Serial.print(analogRead(tempSensorPin));
    
    Serial.print("  Button=");
    Serial.print(digitalRead(buttonPin));

    Serial.print("  Light=");
    Serial.println(analogRead(lightSensorPin)); 
  }
}

注意:打开串口并确定ArduinoIDE的波特率是设置在9600。

演示2 先按照图示把线接好之后,然后用FTDI usb转串口模块把lilypad主控板和电脑连接起来,将下面的程序拷贝到ArduinoIDE上,然后在tool-> board 选择好lilypad的型号,然后在tool->com 选择好端口,然后将程序上传到主控板上

int inputPin = A5;
int outputPin = 5;

void setup() {
  // put your setup code here, to run once:
  pinMode(inputPin,INPUT);
  pinMode(outputPin,OUTPUT);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  if(inputPin == 1) 
  {
     digitalWrite(outPin,HIGH);
  }
  digitalWrite(outputPin,HIGH);
  delay(100);
  digitalWrite(outPin,LOW);
  delay(100);
}


Lilypad light.gif

电路图和PCB

电源

Arduino LilyPad可以通过USB连接或者外部电源供电,电压可从2.7V到5.5V,需要注意Arduino LilyPad没有保护电路,输入电压不能正负接反也不能超过阀值。

存储器

ATmega168包括了片上16KB Flash,其中2KB用于Bootloader。同时还有1KB SRAM和0.5KB EEPROM。

通信接口

  1. 串口:ATmega328内置的UART可以通过数字口0(RX)和1(TX)与外部实现串口通信。
  2. TWI(兼容I2C)接口:
  3. SPI 接口:
  4. 蓝牙模块Bluegiga WT11为Arduino BT提供了蓝牙通信能力。WT11 与ATmega328之间通过串口信号连接,其通信波特率为 115200。该模块与计算机的蓝牙设备通讯连接上后将会提供一个虚拟串口。WT11 的设备名字设置为ARDUINOBT,密码为12345

物理特征

Arduino LilyPad为圆形其直径50.8mm,印制板本身的厚度只有1/32 inches(0.8mm)。

注意要点

  • Arduino LilyPad可以水洗,当然要先断开电源。
  • Arduino LilyPad没有电源保护电路,因此接入电源必须小心。
  • Arduino LilyPad的使用相对来说要复杂一些,具体参见http://arduino.cc/en/Guide/ArduinoLilyPad

资源


LilyPad 程序: 文件:Lilypad dev v11.zip

如何购买

扩展阅读

ProtoSnap - LilyPad Development Board Quickstart Guide