목록전체 글 (20)
STUDY BLOG
명품 C++ programming Chapter 07 예제 예제 7-1 프랜드 함수 만들기 #include using namespace std; class Rect; bool equals(Rect r, Rect s); class Rect { int width, height; public: Rect(int width, int height) { this->width=width; this->height=height; } friend bool equals(Rect r, Rect s); }; bool equals(Rect r, Rect s) { if(r.width==s.width && r.height==s.height) return true; else return false; } int main() { Rect ..
명품 C++ programming Chapter 06 예제 예제 6-1 big() 함수 중복 연습 #include using namespace std; int big(int a, int b) { if(a>b) return a; else return b; } int big(int a[], int size){ int res = a[0]; for(int i=1; i
명품 C++ Programming Chapter 05 예제 예제 5-1 '값에 의한 호출' 시 매개 변수의 생성자 실행되지 않음 #uinclude using namespace std; class Circle { private: int radius; public: Circle(); Circle(int r); ~Circle(); double getArea() { return 3.14*radius*radius; } int getRadius() { return radius; } void setRadius(int radius) { this->radius = radius; } }; Circle::Circle() { radius = 1; cout
시리얼 모니터에 r 입력시 빨간불 on 한번 더 입력 시 off 시리얼 모니터에 g 입력시 초록불 on 한번 더 입력 시 off 시리얼 모니터에 b 입력시 파란불 on 한번 더 입력 시 off unsigned char c; const int pinLEDR=10; const int pinLEDG=11; const int pinLEDB=12; int red=0; int green=0; int blue=0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(pinLEDR, OUTPUT); pinMode(pinLEDG, OUTPUT); pinMode(pinLEDB, OUTPUT); pinMode(Serial.r..
가만히 있으면 RGB LED 모듈 OFF 틸트센서 기울이면 REB LED 모듈 모든 색상 ON const int pinTilt = 2; const int pinLED_R = 10; const int pinLED_G = 9; const int pinLED_B = 8; int val = 0; void setup() { // put your setup code here, to run once: pinMode(pinLED_R, OUTPUT); pinMode(pinLED_G, OUTPUT); pinMode(pinLED_B, OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: val = analogRea..