Skip to content

Declare counter variable in for statements #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Language/Structure/Control Structure/break.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ subCategories: [ "제어 구조" ]
[source,arduino]
----
int threshold = 40;
for (x = 0; x < 255; x ++) {
for (int x = 0; x < 255; x ++) {
analogWrite(PWMpin, x);
sens = analogRead(sensorPin);
if (sens > threshold) { // bail out on sensor detect
Expand Down
2 changes: 1 addition & 1 deletion Language/Structure/Control Structure/continue.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ subCategories: [ "제어 구조" ]
아래 코드는 0에서 255까지의 코드 값을 `PWMpin` 에 쓰지만, 41에서 119 의 범위 값은 건너뛴다.
[source,arduino]
----
for (x = 0; x <= 255; x ++) {
for (int x = 0; x <= 255; x ++) {
if (x > 40 && x < 120) { // 값 중 건너뛸 것을 만듦
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions Language/Variables/Data Types/array.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ BASIC, 자바와 달리, C++ 컴파일러는 배열 액세스가 선언한 배

[source,arduino]
----
int i;
for (i = 0; i < 5; i = i + 1) {
for (byte i = 0; i < 5; i = i + 1) {
Serial.println(myPins[i]);
}
----
Expand Down
5 changes: 2 additions & 3 deletions Language/Variables/Utilities/PROGMEM.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const PROGMEM uint16_t charSet[] = { 65000, 32796, 16843, 10, 11234};
const char signMessage[] PROGMEM = {"I AM PREDATOR, UNSEEN COMBATANT. CREATED BY THE UNITED STATES DEPART"};

unsigned int displayInt;
int k; // counter variable
char myChar;


Expand All @@ -81,14 +80,14 @@ void setup() {

// put your setup code here, to run once:
// read back a 2-byte int
for (k = 0; k < 5; k++) {
for (byte k = 0; k < 5; k++) {
displayInt = pgm_read_word_near(charSet + k);
Serial.println(displayInt);
}
Serial.println();

// read back a char
for (k = 0; k < strlen_P(signMessage); k++) {
for (byte k = 0; k < strlen_P(signMessage); k++) {
myChar = pgm_read_byte_near(signMessage + k);
Serial.print(myChar);
}
Expand Down
5 changes: 2 additions & 3 deletions Language/Variables/Utilities/sizeof.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ subCategories: [ "유틸리티" ]
[source,arduino]
----
char myStr[] = "this is a test";
int i;

void setup() {
Serial.begin(9600);
}

void loop() {
for (i = 0; i < sizeof(myStr) - 1; i++) {
for (byte i = 0; i < sizeof(myStr) - 1; i++) {
Serial.print(i, DEC);
Serial.print(" = ");
Serial.write(myStr[i]);
Expand All @@ -69,7 +68,7 @@ void loop() {

[source,arduino]
----
for (i = 0; i < (sizeof(myInts) / sizeof(myInts[0])); i++) {
for (byte i = 0; i < (sizeof(myInts) / sizeof(myInts[0])); i++) {
// myInts[i] 가지고 무언가를 함
}
----
Expand Down