Week 13

--Originally published at PZ

 

alanEn esta semana aprendimos algo que puede ser bastante simple el cual es la herramienta  SciLab que es un software para análisis numérico. El cual en un futuro me puede ayudar mucho en la cuestión de crear y desarrollar formulas, en este caso para probar la herramienta use una de las formulas de aceleración constante la cual es xf=x0 +vi*t+a*t=

Entendi la aplicacion gracias a este video:


Proyecto Final

--Originally published at PZ

Es una realidad que el mundo ha evolucionado y que mucho de esto se debe al avance tecnológico, es por eso que las cosas mas simples y útiles han tenido un gran avance en los últimos años. Es por eso que decidí crear este proyecto en el cual  innove el dado convirtiéndolo en un aparato electrónico. El dado electrónico fue hecho en arduino, a continuación una lista de los materiales y su función:

  • 7 leds: Su función es obvia y esencial pues cada LED simula los típicos puntos negros del dado.
  • 13 Jumpers: Su función es transmitir la corriente.
  • Arduino UNO: Todos sabemos que el arduino es el aparato principal es como una mini computadora de nuestro dado.
  • Buzzer: Emite un sonido cada que se crea un nuevo número.
  • Resitencias

 

El código es simple y utiliza muchos de las cosas vistas en clase por ejemplo el for utilizado para darle un valor digital a cada led en lugar de tener que poner led1=1, led2 =2, etc. coloque un for para que emita este proceso 7 veces.

Después cree una función llamada mi función la cual hace que los leds se prenden y se apaguen con una secuencia, esto para hacer mas atractivo el dado.

Tercero, cree una función llamada apagatodos donde se apagan todos los leds utilizando el for de igual manera para ahorrar el proceso.

 

Cuarto, se crea la función principal la cual se hace con switch y case, dando 6 cases simulando los 6 números que se pueden crear.

Por último, en el loop principal se coloca un if para leer si el push button está presionado o no.

Codigo

https://www.dropbox.com/s/bfq8s7t0bcsuxeu/dadoelectronico.txt?dl=0


Euler

--Originally published at PZ

El euler es uno de los números irracionales mas importantes, el problema de euler es que al igual que pi es numero infinito, entonce nuestro labor fue calcular los decimales el numero de veces necesaria por medio de una suma infinita.

La actividad numero 12 fue mas simple de lo que esperaba el único problema que tuve fue que me falto  hacer un calculo que en código le llamo fact, pues había hecho de manera correcta la función de calcular e pero me faltaba eso por eso estaba incorrecto mi código.  Lo que me ayudo mucho a entender el código que utiliza una suma infinita fue este vídeo el cual recomiendo mucho. https://www.youtube.com/watch?v=BEGp0XUDG-w&t=740s

wsq12

https://www.dropbox.com/s/g5ihimjlqxms12z/wsq12.cpp?dl=0


Go bananas

--Originally published at PZ

 

Ok, for me this was very difficult because I thought it would be much easier than that, I though that it was going to be very similar to a quiz that we did  where we had to find the char o, so I used that quiz as a base.

But then I realize that I will need to find  something that traduce the text from BanNana or baNNAna to banana so I found this blogs.

http://www.cplusplus.com/reference/cctype/tolower/

In the video the only difference is that he uses toupper.

Then I was stuck because I did not know what to do next to find the word banana, but then I find Fabrizzio Cortez blog who is a mechatronic engineer that did a very good job and uplouded high quality reviews. In the video I noticed that I must use .find which help us to find the word that we want, and also break to end the infinite loops.

In my code I wrote some notes: https://www.dropbox.com/s/be47iyu197epf64/wsq11.cpp?dl=0


Estructura Struct

--Originally published at PZ

Bueno el propósito de este post es explicar un tema que me pario bastante interesante pues es un salto a las estructuras que ya conocemos en C++, como ya sabemos arrays son un tipo de estructura que solo te permite almacenar de un solo tipo de información por ejemplo, 5 datos de tipo int, o 5 de tipo float. A diferencia, struct te permite almacenar datos de diferentes tipos como 2 de int, 3 de float, 1 char etc. esto nos permite hacer cosas mucho mas complejas como por ejemplo guardar la información de una persona, el nombre, edad y estatura, datos que no se podrían en arrays por que son de tipo diferentes.

A continuación les dejo un ejemplo de código que hice, y un vídeo de Youtube que me ayudo a entender todo.

Codigo https://www.dropbox.com/s/n71soq3kysxu128/struc2.cpp?dl=0

 

Imagen de PIRO4D

https://pixabay.com/es/azul-cubo-dise%C3%B1o-moderno-2137334/


Babylonian method

--Originally published at PZ

El método babilonio fue bastante fácil, mucho mas de lo que esperaba pues s tuve que repasar el método while para lograr un buen loop, ademas encontré una pagina (la dejo en referencias ) que me ayudo mucho a entender el método, el único problema que tuve fue al hacer el while no sabia con que valor tenia que comparar el guess number para que parara hasta que fuera la raíz, pero encontré un vídeo en youtube que me ayudo mucho.

Referencias

Babylonian method;

Square roots with pencil and paper: the Babylonian method

Video Youtube

Imagen

Autor Geralt

https://pixabay.com/es/matem%C3%A1ticas-f%C3%B3rmula-f%C3%ADsica-escuela-1509559/

 

Codigo https://www.dropbox.com/s/ed8lzqftki9f309/wsq10.cpp?dl=0wsq10

 

 

 

 


Final Proyect

--Originally published at PZ

My final proyect will be done in Arduino which  “is an open-source electronics platform based on easy-to-use hardware and software. It’s intended for anyone making interactive projects”(Arduino). Arduino combines programming and electroning which will be very helpful in the future of my carrer and that is why I choose Arduino because it will help me to create very interesting proyects, and it will also introduce me to a more difficult program like raspberry. Arduino uses its own programming lenguage based in Wiring, but I think that is also very similar to C++. I decided to create an electronice dice, and I will need 9 LEDS and 1 push button so every time I push the button the LEDS should form a random number just like a dice does.

Calendar:

calendar

Reference

https://www.arduino.cc/en/Guide/Introduction

Foto:

Diego Barruffa

https://pixabay.com/es/dados-juego-azar-suerte-cubo-2777809/


WSQ09

--Originally published at PZ

This week assignment was much more easy than the wsq 8, but I think that this was more interesting and mean a very big step bacause now Im working with a text file that is not in the .cpp file.

First and the most important was to learn de library fstream that is required to read a file of text, I watched this video that help me a lot https://www.youtube.com/watch?v=xZh0oRKIPCw

After that I searche on how to count characters and lines, and for that I used the library string, that we have already seen, and getline(). I used this https://www.youtube.com/watch?v=5xEkuvTxQ4Y&index=46&t=524s&list=WL video as reference and also a blog from my friend Esteban who helped me a lot https://blogdeesteban.000webhostapp.com/.

Codigo

#include <iostream>
#include <string>
#include <fstream>

 

using namespace std;

int main() {

int car=0,lines=0; //variables para contar caracteres y lineas
ifstream ar; // definir la variable de texto

string input;
ar.open(“prueba.txt”,ios::in); //abrir el archivo prueba

while (!ar.eof()) {
getline(ar,input,’\n’); //del archivo ar guardad como input lo que hay ahi hasta que se de enter
car +=input.size();
lines++;
}
cout<<“El numero de caracteres es :”<<car<<endl;
cout<<“El numero de renglones es :”<<lines<<endl;

 

 

return 0;

 

}


Arrays

--Originally published at PZ

Its the perfect moment to start working with arrays and vector, both are amazing topics that will help me a lot in the future, because it is imposible to make a programm with a huge amount of numbers with out arrays or vectors.

To be honest I didnt know what both of the are, before doing this work, but when I start researching in YouTube I discovered that this was an amazing topic. I watched this video to understand the topic https://www.youtube.com/watch?v=gCBpGyKyaGU.

Then I searched on how to use standar deviation and I watched this video https://www.youtube.com/watch?v=jMOwnFXz2lc, in this video I also understand on how to use the library math which can be very helpful in the future, even in physics.

Code

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
int size = 10;
float numbers[size];
float suma,prom,desv,varianza;

cout << “Please enter up tp 10 positive numbers.” << endl;

for (int i=0; i < size; i++)
{
cin >> numbers[i];
}

cout << endl;

for (int i=0; i < size; i++)
{
suma += numbers[i];
prom = suma/size;

 

}

for (int i=0; i < size; i++)
{

cout << “Los numeros elegidos son ” << numbers[i]<<endl;
}
for (int i=0; i < size; i++)
{

varianza=varianza+pow((numbers[i]-prom),2);
}
desv=sqrt(varianza/(size-1));

 

cout<<“La suma de los numeros es: “<<suma<<” el promedio es: ” <<prom<<” la desviacion es “<<desv<<endl;

 

return 0;

}

 

 


Factorial Calculator

--Originally published at PZ

This was a very challenging programm for me because I hadnt used Do and While before, I have just used If and Else. So I try to make this factorial calculation with Do and While, so I first searched the structure of this and I found this page.

https://www.programarya.com/Cursos/C++/Ciclos/Ciclo-Do-While

After that I tried to make a formula to calculate the factorial of a number, so I reviewed the formula that I used in sum of numbers and I used as a base with for.

Finally I had problems with the while because I didnt used a string for the variable so I asked Ken and he helped me to finishmy programm.