Search the Community
Showing results for tags 'arduino uno'.
-
I used this guide to try to make my very first thing with arduino and I thought what better than to make my own temperature sensor to put into my PC. I used this guide to help me: https://www.instructables.com/Arduino-LCD-Computer-Temperature-Monitor/ Figured I'd be pretty simple I installed Arduino IDE and ran the ArduinoOHM exe after uploading the code with the COM3 port active but the GPU and CPU temps are displayed as zero but the temperature sensor I put in there works perfectly. I also had open hardware monitor running in the background throughout all of this so should be a non issue. And yes I am using a flash drive to prop up the LCD against the pin headers because I don't want to directly solder yet. Also I don't have much experience with this so if you could explain to me as if I'm a child that'd be great
-
- arduino
- arduino uno
-
(and 1 more)
Tagged with:
-
Hey Guys! I hooked up my WS2812 Led Strip to my Arduino and programmed a Light-Mode, but i can't explain myself why the variable "a" isnt getting count up. Code: #include <FastLED.h> #define LED_PIN 2 #define NUM_LEDS 25 CRGB leds[NUM_LEDS]; int segNr = 0; void setup() { FastLED.addLeds<WS2812, LED_PIN, RBG>(leds, NUM_LEDS); FastLED.setMaxPowerInVoltsAndMilliamps(5, 500); FastLED.clear(); FastLED.show(); Serial.begin(9600); Serial.print("Setup 1: "); Serial.println(segNr); segNr = 15; Serial.print("Setup 2: "); Serial.println(segNr); } void loop() { // put your main code here, to run repeatedly: //leds[0] = CRGB(255, 0, 0); //leds[1] = CRGB(0, 255, 0); //leds[2] = CRGB(0, 0, 255); nightrider(); } void nightrider() { Serial.print("Anfang: "); Serial.println(segNr); if (segNr >= 25) { Serial.print("Reset: "); Serial.println(segNr); segNr = 0; } else { Serial.print("Set 1: "); Serial.println(segNr); for (int i = 0; i <= NUM_LEDS; i++) { leds[i] = CRGB(255, 255, 255); } Serial.print("Set 2: "); Serial.println(segNr); leds[segNr] = CRGB(255, 0, 0); } FastLED.show(); delay(500); segNr++; Serial.print("Ende: "); Serial.println(segNr); } void randomcoloreffect() { for (int i = 0; i <= 25; i++) { leds[i] = CRGB(random(0, 255), random(0, 255), random(0, 255)); } FastLED.show(); delay(1000); } My Serial output is really weird because im getting "0" at "Set1:" and "-1" at "Set2".But i dont know why the for loop effects the a variable. Thanks for your help.
- 2 replies
-
- arduino
- arduino uno
-
(and 1 more)
Tagged with:
-
I need some help finding some projects for my arduino uno. Just to make it slightly easier for typing stuff in, here is a link to the kit i have so u can see the parts: https://www.sunfounder.com/learn/category/From-Knowing-To-Utilizing-Kit-V2-0-for-Arduino.html I didnt know if I should put this here or in Hobby Electronics, but if u r a mod, just move it. -Piero
- 5 replies
-
- arduino uno
- arduino projects
-
(and 1 more)
Tagged with:
-
Does anyone know how to code this on an Arduino UNO? https://www.dfrobot.com/product-1670.html I got 2pcs. of the module but I can't make it work since I don't have a library for it. The product site doesn't give much info and there are no examples that I can use. I tried getting random sketches from the Arduino IDE but it's for specific boards/modules. All I need to do is to send and receive data back and forth on the 2 modules which should be a simple task. If I don't have a library, does that mean I can't use it on the Arduino? But if I can use it with the Arduino, how do you set up the parameters of the module? Anyone who can help is a godsend
- 11 replies
-
- arduino uno
- uno
-
(and 3 more)
Tagged with:
-
Some time ago a dabbled with the Arduino platform, trying to make a DCC command station. For those who don't know, DCC is a standard in the world of small/miniature railways. North American readers can find the specs/standards with the NMRA online. But that aside. So I found a sketch on the web for a basic DCC command station and using the pin-outs and appropriate driver chip, I established it worked. Next, I wanted to create the RailCom cutout. Again, this is a technique used in the DCC world to make a bidirectional transmission possible. It required the outputs of the driver chip are short-circuited, by the chip. After quite some study (I'm not a coder!) I figured out I needed to add another case to the switch-case machine inside the code. So I did, and it doesn't work. The RailCom cutout case is never called. This tells me the conditions for it are never met, but I can't see what I'm doing wrong. Any ideas? Here's the code: // 23. November 2009 // works well with LMD18200 Booster !!!!! /*Copyright (C) 2009 Michael Blank This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #define DCC_PIN 4 // Arduino pin for DCC out // this pin is connected to "DIRECTION" of LMD18200 #define DCC_PWM 5 // must be HIGH for signal out // connected to "PWM in" of LMD18200 #define DCC_THERM 7 // thermal warning PIN #define AN_SPEED 2 // analog reading for Speed Poti #define AN_CURRENT 0 // analog input for current sense reading #define DCC_BRAKE 6 // brake pin of driver, low for operation, high for railcom cutout //Timer frequency is 2MHz for ( /8 prescale from 16MHz ) #define TIMER_SHORT 0x8D // 58usec pulse length #define TIMER_LONG 0x1B // 116usec pulse length unsigned char last_timer=TIMER_SHORT; // store last timer value unsigned char flag=0; // used for short or long pulse unsigned char every_second_isr = 0; // pulse up or down // definitions for state machine #define PREAMBLE 0 #define SEPERATOR 1 #define SENDBYTE 2 #define RAILCOM 3 unsigned char state= PREAMBLE; unsigned char preamble_count = 16; unsigned char outbyte = 0; unsigned char cbit = 0x80; // variables for throttle int locoSpeed=0; int dir; int last_locoSpeed=0; int last_dir; int dirPin = 12; int FPin[] = { 8,9,10,11}; int maxF =3; int locoAdr=40; // this is the (fixed) address of the loco // buffer for command struct Message { unsigned char data[7]; unsigned char len; } ; #define MAXMSG 2 // for the time being, use only two messages - the idle msg and the loco Speed msg struct Message msg[MAXMSG] = { { { 0xFF, 0, 0xFF, 0, 0, 0, 0}, 3}, // idle msg { { locoAdr, 0x3F, 0, 0, 0, 0, 0}, 4} // locoMsg with 128 speed steps }; // loco msg must be filled later with speed and XOR data byte int msgIndex=0; int byteIndex=0; //Setup Timer2. //Configures the 8-Bit Timer2 to generate an interrupt at the specified frequency. //Returns the time load value which must be loaded into TCNT2 inside your ISR routine. void SetupTimer2(){ //Timer2 Settings: Timer Prescaler /8, mode 0 //Timmer clock = 16MHz/8 = 2MHz oder 0,5usec TCCR2A = 0; TCCR2B = 0<<CS22 | 1<<CS21 | 0<<CS20; //Timer2 Overflow Interrupt Enable TIMSK2 = 1<<TOIE2; //load the timer for its first cycle TCNT2=TIMER_SHORT; } //Timer2 overflow interrupt vector handler ISR(TIMER2_OVF_vect) { //Capture the current timer value TCTN2. This is how much error we have //due to interrupt latency and the work in this function //Reload the timer and correct for latency. // for more info, see http://www.uchobby.com/index.php/2007/11/24/arduino-interrupts/ unsigned char latency; // for every second interupt just toggle signal if (every_second_isr) { digitalWrite(DCC_PIN,1); every_second_isr = 0; // set timer to last value latency=TCNT2; TCNT2=latency+last_timer; } else { // != every second interrupt, advance bit or state digitalWrite(DCC_PIN,0); every_second_isr = 1; switch(state) { case PREAMBLE: flag=1; // short pulse preamble_count--; if (preamble_count == 0) { // advance to next state state = SEPERATOR; // get next message msgIndex++; if (msgIndex >= MAXMSG) { msgIndex = 0; } byteIndex = 0; //start msg with byte 0 } break; case SEPERATOR: flag=0; // long pulse // then advance to next state state = SENDBYTE; // goto next byte ... cbit = 0x80; // send this bit next time first outbyte = msg[msgIndex].data[byteIndex]; break; case SENDBYTE: if (outbyte & cbit) { flag = 1; // send short pulse } else { flag = 0; // send long pulse } cbit = cbit >> 1; if (cbit == 0) { // last bit sent, is there a next byte? byteIndex++; if (byteIndex >= msg[msgIndex].len) { // this was already the XOR byte then advance to railcom cutout state = RAILCOM; preamble_count == 16; } else { // send separator and advance to next byte state = SEPERATOR ; } } break; case RAILCOM: // state = NOTHING; // make nothing happen until RAILCOM is done sei(); digitalWrite(DCC_PIN,1); delayMicroseconds(26); digitalWrite(DCC_PWM,0); digitalWrite(DCC_PIN,0); digitalWrite(DCC_BRAKE,1); delayMicroseconds(4); digitalWrite(DCC_PWM,1); delayMicroseconds(464); digitalWrite(DCC_PWM,0); delayMicroseconds(4); digitalWrite(DCC_BRAKE,0); delayMicroseconds(12); digitalWrite(DCC_PIN,1); state = PREAMBLE; return; } if (flag) { // if data==1 then short pulse latency=TCNT2; TCNT2=latency+TIMER_SHORT; last_timer=TIMER_SHORT; } else { // long pulse latency=TCNT2; TCNT2=latency+TIMER_LONG; last_timer=TIMER_LONG; } } } void setup(void) { //Set the pins for DCC to "output". pinMode(DCC_PIN,OUTPUT); // this is for the DCC Signal pinMode(DCC_PWM,OUTPUT); // will be kept high, PWM pin digitalWrite(DCC_PWM,1); pinMode(DCC_THERM, INPUT); digitalWrite(DCC_THERM,1); //enable pull up pinMode(dirPin, INPUT); digitalWrite(dirPin, 1); //enable pull-up resistor !! for (int i=0 ; i<=maxF; i++){ pinMode(FPin[i], INPUT); digitalWrite(FPin[i], 1); //enable pull-up resistor } read_locoSpeed_etc(); assemble_dcc_msg(); //Start the timer SetupTimer2(); } void loop(void) { delay(200); if (read_locoSpeed_etc()) { // some reading changed // make new dcc message assemble_dcc_msg(); ; } } boolean read_locoSpeed_etc() { boolean changed = false; // read the analog input into a variable: // limit range to 0..127 locoSpeed = (127L * analogRead(AN_SPEED))/1023; if (locoSpeed != last_locoSpeed) { changed = true; last_locoSpeed = locoSpeed; } dir = digitalRead(dirPin); if (dir != last_dir) { changed = true; last_dir = dir; } return changed; } void assemble_dcc_msg() { int i; unsigned char data, xdata; if (locoSpeed == 1) { // this would result in emergency stop locoSpeed = 0; } // direction info first if (dir) { // forward data = 0x80; } else { data = 0; } data |= locoSpeed; // add XOR byte xdata = (msg[1].data[0] ^ msg[1].data[1]) ^ data; noInterrupts(); // make sure that only "matching" parts of the message are used in ISR msg[1].data[2] = data; msg[1].data[3] = xdata; interrupts(); } Note that I didn't add any copyright for my code contribution as it's not done yet The code itself works, as if the entire RailCom cutout case wasn't there. I'm lost, hopefully someone can enlighten me what I did wrong. TIA!
-
So I got this code from a buddy of mine. And I had to make the part of the servos and the part of the led blinking go parallel. #include <Servo.h> Servo motor1; Servo motor2; void setup() { motor1.attach(6); motor2.attach(5); pinMode(13,OUTPUT); } void loop() { motor1.write(86); motor2.write(99); delay(1200); motor1.write(90); motor2.write(92); delay(1000); motor1.write(95); motor2.write(86); delay(1310); motor1.write(90); motor2.write(92); delay(4000); if (analogRead(A0) > 300) { digitalWrite(13, HIGH); delay(400); digitalWrite(13, LOW); delay(100); digitalWrite(13, HIGH); delay(300); digitalWrite(13, LOW); delay(200); } else { digitalWrite(13, LOW); } } In which I succeeded, see code below. #include <Servo.h> Servo motor1; Servo motor2; unsigned long previousMillis1 = 0; unsigned long currentMillis1 = millis(); unsigned long previousMillis2 = 0; unsigned long currentMillis2 = millis(); void setup() { motor1.attach(6); motor2.attach(5); pinMode(13,OUTPUT); } void loop() { if (currentMillis1 - previousMillis1 >= 0){ previousMillis1 = currentMillis1; motor1.write(86); motor2.write(99); //delay(1200); if (currentMillis1 - previousMillis1 >= 1200){ previousMillis1 = currentMillis1; motor1.write(90); motor2.write(92); //delay(1000); if (currentMillis1 - previousMillis1 >= 1000){ previousMillis1 = currentMillis1; motor1.write(95); motor2.write(86); //delay(1310); if (currentMillis1 - previousMillis1 >= 1310){ previousMillis1 = currentMillis1; motor1.write(90); motor2.write(92); //delay(4000); if (currentMillis1 - previousMillis1 >= 4000){ previousMillis1 = currentMillis1; } } } } } //als de afstandssensor hoger meet dan 300 if (analogRead(A0) > 300) { // gaat het lampje knipperen if (currentMillis2 - previousMillis2 >= 0){ previousMillis2 = currentMillis2; digitalWrite(13, HIGH); //delay(400); if (currentMillis2 - previousMillis2 >= 400){ previousMillis2 = currentMillis2; digitalWrite(13, LOW); //delay(100); if (currentMillis2 - previousMillis2 >= 100){ previousMillis2 = currentMillis2; digitalWrite(13, HIGH); //delay(300); if (currentMillis2 - previousMillis2 >= 300){ previousMillis2 = currentMillis2; digitalWrite(13, LOW); //delay(200); if (currentMillis2 - previousMillis2 >= 200){ previousMillis2 = currentMillis2; } } } } } } else { digitalWrite(13, LOW); } } But the problem is as following: The servos aren't rotating back and forth like they used to do. But now they're rotating at a continuous speed. I hope that you guys can see the problem because I cant. Thanks in advance, Anton
-
Hi! I need help with making this code work, the comments is mostly in norwegian but i hope one of you can help me ASAP! Thanks before hand! Jóni trafikklys_med_knapp.ino
- 5 replies
-
- arduino
- arduino uno
-
(and 3 more)
Tagged with:
-
hi nerds! i'm doing a prosject in school where i need 4 servos to work in patterns, but when i try to code this, the servo only twitch (even though i put it to 180degrees) anyone have som suggestions on how to make them actually move as i want?
- 6 replies
-
- arduino uno
- servo
-
(and 1 more)
Tagged with: