Skip to content

Instantly share code, notes, and snippets.

View RodriAndreotti's full-sized avatar

Rodrigo Teixeira Andreotti RodriAndreotti

View GitHub Profile
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led[5] = {13,12,11,10,9};
int btnLargada = 5;
bool largadaIniciada = false;
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int botao = 12;
int sensor = 8;
int motor1 = 5;
int motor2 = 6;
int estadoBotao = LOW;
int estadoBotaoAntigo = LOW;
const int botao = 12;
const int led = 8;
int estadoBotao = 0;
void setup()
{
pinMode(led, OUTPUT);
pinMode(botao, INPUT);
}
void loop()
{
@RodriAndreotti
RodriAndreotti / servo.ino
Created May 27, 2017 14:40
Servo Arduino
#include <Servo.h>
#define SERVO 9
Servo s;
int pos;
// give it a name:
const int btn1 = 3;
const int btn2 = 4;
const int btn3 = 5;
@RodriAndreotti
RodriAndreotti / seta_automovel.ino
Last active April 4, 2017 23:35
Simulação de Seta automotiva em Arduino
const int led_right = 8;
const int led_left = 9;
const int btn1 = 2;
const int btn2 = 3;
const long intervalo = 500; // intervalo para o led piscar
unsigned long millisAnterior = 0; // Armazena o último tempo para a próxima contagem
@RodriAndreotti
RodriAndreotti / calcula_irrf.php
Created December 10, 2016 15:22
Exemplo de cálculo de IRRF com Funções
<?php
function calculaIRRF($salario) {
if($salario < 1903.98) {
$desconto = 0;
}
elseif($salario <= 2826.65){
$desconto = 7.5;
}
elseif($salario <= 3751.5) {
$desconto = 15;
@RodriAndreotti
RodriAndreotti / fatorial.php
Created November 27, 2016 23:42
Cálculo de Fatorial
<?php
$n = 10;
$fatorial = 0;
for($i = 0; $i <= 10; $i++) {
if($i == 0) {
$fatorial = 1;
}
else{
@RodriAndreotti
RodriAndreotti / fibonacci.php
Created November 27, 2016 21:35
Sequência de Fibonacci
<?php
$fib = array();
for($i = 0; $i < 10; $i++){
if($i < 2){
$fib[$i] = $i;
} else {
$fib[$i] = $fib[$i - 1] + $fib[$i-2];
}
}
@RodriAndreotti
RodriAndreotti / numero_primo_blog
Created October 1, 2016 20:38
Verifica se um número é primo ou não.
<?php
$numero = 101;
if($numero % 2 == 0){
// Nenhum número par, exceto 2 é primo
if($numero == 2){
echo 'É um número primo';
}
else{
echo 'Não é um número primo';
@RodriAndreotti
RodriAndreotti / par_impar_blog.php
Last active October 1, 2016 20:09
Código que verifica se um número é par ou ímpar
<?php
$numero = 49;
if($numero % 2 == 0){
echo "O número é par";
}
else {
echo "O número é ímpar!";
}