sin()

설명

각(라디안)의 사인 계산. 결과는 -1과 1 사이.

문법

sin(rad)

매개변수

  • rad: 라디안 각 (float).

반환값

  • 각의 사인 값 (double).

예제 코드

void setup() { Serial.begin(9600); for (int angle = 0; angle <= 180; angle += 15) { float angle_rad = angle * M_PI / 180; float sin_result = sin(angle_rad); Serial.print("sin("); Serial.print(angle); Serial.print("°) = "); Serial.println(sin_result); } } void loop() { }

The result in Serial Monitor:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
sin(0°) = 0.00 sin(15°) = 0.26 sin(30°) = 0.50 sin(45°) = 0.71 sin(60°) = 0.87 sin(75°) = 0.97 sin(90°) = 1.00 sin(105°) = 0.97 sin(120°) = 0.87 sin(135°) = 0.71 sin(150°) = 0.50 sin(165°) = 0.26 sin(180°) = -0.00
Ln 11, Col 1
Arduino Uno on COM15
2

더보기

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .

※ OUR MESSAGES