BASIC4MCU | 질문게시판 | 답변 : 진동모터 작동
페이지 정보
작성자 master 작성일2019-11-28 17:54 조회3,335회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=10952
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-11-28 오후 5:53:56// by Ok-Hyun Park색상값이 R,G값이 95이상이면 진동모터를 작동시키고싶은데 진동모터가 작동하지않아서 코드의 문제가있나싶어서 질문드립니다.//#include <Wire.h>#include "Adafruit_TCS34725.h"//#define motor 7#define redpin 3#define greenpin 5#define bluepin 6//#define commonAnode true//byte gammatable[256];Adafruit_TCS34725 tcs=Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS,TCS34725_GAIN_4X);//void setup(){Serial.begin(9600);//if(tcs.begin()){} //Serial.println("Found sensor");else{ Serial.println("No TCS34725 found...check your connections"); while(1); } // halt!//pinMode(motor,OUTPUT);pinMode(redpin,OUTPUT); pinMode(greenpin,OUTPUT); pinMode(bluepin,OUTPUT);//for(int i=0; i<256; i++){float x=i;x/=255; x=pow(x,2.5); x*=255;if(commonAnode){ gammatable[i]=255-x; }else { gammatable[i]=x; }}}//void loop(){float red,green,blue;//tcs.setInterrupt(false); // turn on LEDdelay(60);tcs.getRGB(&red,&green,&blue);tcs.setInterrupt(true); // turn off LED//Serial.print("R: \t"); Serial.print(int(red));Serial.print("\tG: \t"); Serial.print(int(green));Serial.print("\tB: \t"); Serial.print(int(blue));Serial.print("\n");//analogWrite(redpin,gammatable[(int)red]);analogWrite(greenpin,gammatable[(int)green]);analogWrite(bluepin,gammatable[(int)blue]);//if((red>95)&&(green>95)&&(blue<95)){ // R,G값이 95이상이면digitalWrite(motor,HIGH);}else{ digitalWrite(motor,LOW); }//delay(100);}
댓글 0
조회수 3,335등록된 댓글이 없습니다.