This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <VL6180X.h> | |
#define SPEAKER 8 | |
VL6180X sensor; | |
void setup() | |
{ | |
Serial.begin(9600); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int VOL_PIN = A0; | |
void setup(){ | |
Serial.begin( 9600 ); | |
} | |
void loop(){ | |
int value; | |
float volt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int DIN_PIN = 7; | |
const int LED_PIN = 13; | |
void setup(){ | |
pinMode( DIN_PIN, INPUT_PULLUP ); | |
pinMode( LED_PIN, OUTPUT ); | |
} | |
void loop(){ | |
int value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int DIN_PIN = 7; | |
void setup(){ | |
pinMode( DIN_PIN, INPUT_PULLUP ); | |
Serial.begin( 9600 ); | |
} | |
void loop(){ | |
int value; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int DIN_PIN = 7; | |
void setup(){ | |
pinMode( DIN_PIN, INPUT ); | |
Serial.begin( 9600 ); | |
} | |
void loop(){ | |
int value; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIDTH 5//LEDの横の数 | |
#define HEIGHT 5//LEDの縦の数 | |
#define LED_PIN 6//LEDテープの信号線 | |
#define INTERVAL 750//画面切り替えのインターバル | |
#define MAX_BRIGHTNESS 32//動植物の最大の明るさ | |
#define ANIMAL_MAX_NUM 10//動物の最大数 | |
#define ANIMAL_DECREASE 1//動物の体力減少 | |
#define GRASS_GROWTH_NUM 3//同時に草が成長する箇所 | |
#define GRASS_GROWTH_POTENTIAL 2//草が成長するスピード | |
#define KNOCK_THRESHOLD 5000//ノックと判断する閾値 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. #define WIDTH 5//LEDの横の数 | |
2. #define HEIGHT 5//LEDの縦の数 | |
3. #define LED_PIN 6//LEDテープの信号線 | |
4. #define INTERVAL 750//画面切り替えのインターバル | |
5. #define MAX_BRIGHTNESS 32//動植物の最大の明るさ | |
6. #define ANIMAL_MAX_NUM 10//動物の最大数 | |
7. #define ANIMAL_DECREASE 1//動物の体力減少 | |
8. #define GRASS_GROWTH_NUM 3//同時に草が成長する箇所 | |
9. #define GRASS_GROWTH_POTENTIAL 2//草が成長するスピード | |
10. #define KNOCK_THRESHOLD 5000//ノックと判断する閾値 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
//体力が上限になったら増える | |
if ( animals[i].life > MAX_BRIGHTNESS ) | |
{ | |
animals[i].life = MAX_BRIGHTNESS / 2; | |
bornAnimal(i); | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// 加速度センサーが反応していれば、動物を増やす | |
if ( bornFlag ) | |
{ | |
bornFlag = false; | |
bornAnimal(-1); | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
struct Animal | |
{ | |
float x; | |
float y; | |
int life; | |
bool isDead; | |
RGB color; | |
}; |